Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Two issues: Failed to init I2C & Reef-pi.service not Binding
#1
Me again.

Likely some stupid mistakes on my part.  Let's start with the service not binding to the IP.  I get this every time I reboot the pi:
Code:
May 10 20:09:52 nautilus reef-pi[415]: 2023/05/10 20:09:52 Successfully started subsystem: temperature
May 10 20:09:52 nautilus reef-pi[415]: 2023/05/10 20:09:52 Successfully started subsystem: doser
May 10 20:09:52 nautilus reef-pi[415]: 2023/05/10 20:09:52 Successfully started subsystem: phprobes
May 10 20:09:52 nautilus reef-pi[415]: 2023/05/10 20:09:52 Successfully started subsystem: macro
May 10 20:09:52 nautilus reef-pi[415]: 2023/05/10 20:09:52 reef-pi version 6.0 is up and running
May 10 20:09:52 nautilus reef-pi[415]: 2023/05/10 20:09:52 Starting https server at: 192.168.56.219:443
May 10 20:09:52 nautilus reef-pi[415]: 2023/05/10 20:09:52 ERROR: Failed to run https server. Error: listen tcp 192.168.56.219:443: bind: cannot assign requested address
May 10 20:09:52 nautilus reef-pi[415]: Methods: [GET]
May 10 20:09:52 nautilus reef-pi[415]: 2023/05/10 20:09:52 API Doc path: /api/settings
May 10 20:09:52 nautilus reef-pi[415]: 2023/05/10 20:09:52 Starting health checker

If I manually restart the service, it binds fine and the site comes up.  Obviously, this is some form of dependency / race condition.  I assume there is a way to determine what that race condition is, and to set a dependency.  In systemctl?  Guideance is apppriciated.

Second issue is after I get the service started.  I notice the following error:

Code:
Failed to initialize i2c. Error:open /dev/i2c-1: no such file or directory

I do have the following set in my /boot/config.txt and rebooted numerous times since it was set:
Code:
dtparam=i2c_arm=on
This is obviously causing issues with getting the pH probe set up. :P
Reply to top
#2
Hi Blake, sorry but I'm not sure what's going wrong, I think it might be best to try a fresh install from step 1 and hopefully that solves it which it should.

https://docs.google.com/document/d/1t9ma...o3woZ/edit
Reply to top
#3
(05-10-2023, 08:29 PM)Rob F Wrote: Hi Blake, sorry but I'm not sure what's going wrong, I think it might be best to try a fresh install from step 1 and hopefully that solves it which it should.

https://docs.google.com/document/d/1t9ma...o3woZ/edit

Used a second RPi3 I had available.  Brand new (like, pulled it out of the cardboard packer) mSD card.  Followed the linked directions to the letter.

At first, the site was available.  I started fiddling and was able to reproduce the first error conditions successfully across three installs now.  Maybe this is my misunderstanding of how the config utility works, but if so, then the utility needs refinement as it's unintuitive.  Moreover, I think this is a service dependency / race condition issue.

To Repro:
Follow the installation steps as outlined.
Once signed into Reef-pi, change the IP address from 0.0.0.0 to the DHCP-provided IP address (ex: 192.168.1.100)

Workaround:
Stick with a loose / all addresses binding (0.0.0.0)

To Resolve:
If I had to guess, the http service is attempting to start (and therefore bind) before the dhcpcd (DHCP client daemon) service has started / successfully leased an IP from the server.  Since it's looking for a specific address that isn't yet leased, it's unable to start.  I ran the following command: sudo systemctl edit reef-pi.service and added this lines: After=network-online.target and Wants=network-online.target.  This makes the reef-pi.service dependent on the network being fully available.  In prelim testing, that appears to be working.  Broader testing & feedback is welcomed. Nevermind.  Being as neither Network Manager or systemd-networkd is used to manage the network config in your setup script, we don't get NetworkManager-wait-online.service or  systemd-networkd-wait-online.service and therefore we can't use network-online.target. :(

On to the second issue:
Got the SAME results, now with the added bonus of the extra-ports message. :(
Any more ideas?
Code:
May 10 22:38:38
Failed to initialize i2c. Error:open /dev/i2c-1: no such file or directory

May 10 22:39:36
failed to initialize driver: Extra Ports Error: remote I/O error
Reply to top
#4
Ah I see, replacing the 0.0.0.0 with your IP address isn't necessary, I'm actually not sure what that is for but I've changed it in the past and got the same results. Try reinstalling again without changing that.

The 2nd issue seems unrelated but maybe not. The "extra-ports" error is related as it uses the I2C bus with the pH. If after installing this happens again try the following command in the SSH terminal.

sudo raspi-config

That will open a menu, select Interfacing Options and then select I2C.

If it's already set to Yes change it to No and reboot when it asks. Then do this again and select Yes and reboot again. Then run the following command to see if it prints a table of I2C addresses.

sudo i2cdetect -y 1
Reply to top
#5
Couldn't run that command.  It wasn't found... 

Which lead me to run sudo apt-get install i2c-tools and after was able to run both the command and the error went away.  May want to add that to your script or give feedback to the Reef-pi folks.
Reply to top
#6
And running raspi-config, going to Advance Options, then Network Config and selecting Network Manager (instead of dhcpcd) combined with editing /lib/systemd/system/reef-pi.service and adding After=network-online.target and Wants=network-online.target to the [Unit] section will allow for proper binding to a specific IP rather than a loose binding (which fixes the service failing to bind and the site being unavailable).

(Colors added to aid in context.  Not trying for unicorn puke, I promise...)
Reply to top
#7
Right on, glad you were able to solve both issues. The i2c-tools missing is a little strange as that is included in the install script however now I remember a couple others have experienced this but the large majority hasn't. With that said I don't have "sudo" at the beginning giving so maybe that's the reason and only affects a few, I'll have to add it.

Thanks for posting how to solve the binding issue, I always tell people to ignore that setting as this always happens but now I know why.
Reply to top


Possibly Related Threads…
Thread Author Replies Views Last Post
  Issues with Setting Up Telemetry BlakeD 1 884 05-27-2023, 05:30 PM
Last Post: Rob F
  Getting updated reef-pi code from JFReyes JFReyes 76 41,423 10-21-2022, 07:22 PM
Last Post: Rob F
  Reef-Pi or Robo-Tank 6.x Wolfw28 6 2,578 09-01-2022, 01:11 AM
Last Post: Rob F
  reef-pi with v2 controller gandalf 1 1,345 04-06-2022, 12:48 PM
Last Post: Rob F

Forum Jump:

Current time: 03-01-2024, 02:10 AM