We are using a Raspberry Pi 3 from Blue Robotics as the basis for a custom underwater robot being developed. The robot is controlled through a custom python app that we’ve developed. When the app is manually started (logging in through ssh and running the command to start the app) everything works as intended, however, when auto-starting the app through a systemd service we created, the app will sometimes hang indefinitely. The call stack for where the app hangs is roughly below (most recent call last):
- mavutil.recv_match() call in our custom app code with blocking set to True
- the recv_match() definition in mavutil.py:
if m is None:
if blocking:
for hook in self.idle_hooks:
hook(self)
if timeout is None:
self.select(0.05) <---------------------
else:
self.select(timeout/2)
- the select() definition in mavutil.py:
if self.fd is None:
time.sleep(min(timeout,0.5))
return True
try:
(rin, win, xin) = select.select([self.fd], [], [], timeout)
except select.error: <--------------
return False
return len(rin) == 1
I’ve been able to attach pdb to the background process that our systemd service starts up and it is hanging at the except select.error
line.
Through trying various things to get around this, the app still has issues auto-starting and complains about either not being able to communicate with a serial port and afile descriptor not being available. I believe both of these are referencing the Pixhawk connected to the Pi.
The systemd service is set to require and start after the rc.local service since the .companion.rc startup script is run by rc.local. Also we’ve tried just putting a 30 second sleep at the start of our systemd service and that didn’t help. If the systemd service hangs, restarting the service using systemctl seems to fix it. This seems to imply that it’s some kind of race condition and our custom app is starting too soon. However, a 30 second sleep before trying to run our custom app seems like it should be enough time to let any background process finish starting.
I’ve run out of things to try at the moment and was hoping there might be some leads to look into. Thanks in advance for any help!