This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pypilot steals serial GPS from signalk
#31
I tend to think it is best to let gpsd handle the gps and signalk or pypilot to get gps from that, but.. we probably should make it easier for users to completely disable gpsd and eliminate it's presence because that is also a valid configuration and frustrating to achieve.

Consider for example some buggy gps that gpsd has issues dealing with but wont let go of, but the nmea output is "good enough"

Finally, ideally openplotter script that does disable any gps would detect if it is in binary mode and use gpsctl -f -n on the device to ensure it can be used as gpsd does often put these devices in binary mode and the gps will remember this even if unplugged or not powered.

So I guess what I am saying is some sort of gui to allow users to specify what process directly manages the gps, what do you think?
Reply
#32
That made the trick! I deleted the original gps connection in signalK and inserted a new one according to your instructions and now autopilot control is working and also the gps signal comes through.

Thank you ironman!
Reply
#33
Not sure if this is directly related, but pypilot is exiting after a while on my RPI. After it exits, I check gpsd status with cgps, and it appears that the gps is still running and gpsd does not have any errors.

Is there a way to force pypilot to retry if it gets this error?
sensor lost gps gpsd /dev/ttyACM0 Tue Apr 16 07:07:50 2024

gpsd connected
GPSD devices ['/dev/ttyACM0']
sensor found gps gpsd /dev/ttyACM0 Tue Apr 16 07:07:09 2024
calibration loaded, starting 84952
server/client is running too _slowly_ 0.11605840499396436
signalk process 84960
signalkread token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkZXZpY2UiOiI3ZjhiYjM3YS0yMjVkLTQxMGItYmJjMC01M2ZkNDgxZTlmNGIiLCJpYXQiOjE3MTExMjczMTB9.ueM0YTOkOKZnNGAwR4LFp8Ft_zVQoNAxuvdgz65lX28
signalk server found 127.0.0.1:3000
signalk found ws://127.0.0.1:3000/signalk/v1/stream?subscribe=none
signalk connected to ws://127.0.0.1:3000/signalk/v1/stream?subscribe=none
sensor lost gps gpsd /dev/ttyACM0 Tue Apr 16 07:07:50 2024
Traceback (most recent call last):
File "/usr/local/bin/pypilot", line 33, in <module>
sys.exit(load_entry_point('pypilot==0.51', 'console_scripts', 'pypilot')())
File "/usr/local/lib/python3.9/dist-packages/pypilot/autopilot.py", line 519, in main
ap.iteration()
File "/usr/local/lib/python3.9/dist-packages/pypilot/autopilot.py", line 360, in iteration
self.sensors.poll()
File "/usr/local/lib/python3.9/dist-packages/pypilot/sensors.py", line 391, in poll
self.signalk.poll()
File "/usr/local/lib/python3.9/dist-packages/pypilot/signalk.py", line 327, in poll
self.sensors.write(sensor, data, 'signalk')
File "/usr/local/lib/python3.9/dist-packages/pypilot/sensors.py", line 418, in write
self.sensors[sensor].write(data, source)
File "/usr/local/lib/python3.9/dist-packages/pypilot/sensors.py", line 45, in write
if not self.update(data):
File "/usr/local/lib/python3.9/dist-packages/pypilot/sensors.py", line 219, in update
self.speed.set(data['speed'])
KeyError: 'speed'
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib/python3.9/multiprocessing/popen_fork.py", line 27, in poll
pid, sts = os.waitpid(self.pid, flag)
File "/usr/local/lib/python3.9/dist-packages/pypilot/autopilot.py", line 193, in cleanup
raise KeyboardInterrupt # to get backtrace on all processes
KeyboardInterrupt
Reply
#34
Incidentally, for future reference, the way to keep gpsd from opening all of the serial ports exclusively is to edit /etc/default/gpsd
Change this:
USBAUTO="false"
And specify a device:
DEVICES="/dev/ttyACM0"

Now I have gpsd and pypilot running and sending data to SK via serial port (my CAN interface doesn't seem to be working at the moment).
Reply
#35
This is what openplotter-serial app does after installing if /etc/default/gpsd file does not exists:

START_DAEMON="false"
USBAUTO="false"
DEVICES=""
GPSD_OPTIONS="-n -b"'

When you set a device using openplotter-serial and make a connection with gpsd it adds the device to DEVICES and starts the daemon and when you set a connection with pypilot it adds the device to ~/.pypilot/serial_ports file.

Could you check if the problem is fixed using openplotter-serial?

EDIT: I have just found a bug in openplotter-serial setting pypilot connections and it could not work...
Reply
#36
(2024-04-16, 07:44 PM)barnaclebill22 Wrote: Not sure if this is directly related, but pypilot is exiting after a while on my RPI. After it exits, I check gpsd status with cgps, and it appears that the gps is still running and gpsd does not have any errors.

Is there a way to force pypilot to retry if it gets this error?
sensor lost gps gpsd /dev/ttyACM0 Tue Apr 16 07:07:50 2024

gpsd connected
GPSD devices ['/dev/ttyACM0']
sensor found gps gpsd /dev/ttyACM0 Tue Apr 16 07:07:09 2024
calibration loaded, starting 84952
server/client is running too _slowly_ 0.11605840499396436
signalk process 84960
signalkread token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkZXZpY2UiOiI3ZjhiYjM3YS0yMjVkLTQxMGItYmJjMC01M2ZkNDgxZTlmNGIiLCJpYXQiOjE3MTExMjczMTB9.ueM0YTOkOKZnNGAwR4LFp8Ft_zVQoNAxuvdgz65lX28
signalk server found 127.0.0.1:3000
signalk found ws://127.0.0.1:3000/signalk/v1/stream?subscribe=none
signalk connected to ws://127.0.0.1:3000/signalk/v1/stream?subscribe=none
sensor lost gps gpsd /dev/ttyACM0 Tue Apr 16 07:07:50 2024
Traceback (most recent call last):
  File "/usr/local/bin/pypilot", line 33, in <module>
    sys.exit(load_entry_point('pypilot==0.51', 'console_scripts', 'pypilot')())
  File "/usr/local/lib/python3.9/dist-packages/pypilot/autopilot.py", line 519, in main
    ap.iteration()
  File "/usr/local/lib/python3.9/dist-packages/pypilot/autopilot.py", line 360, in iteration
    self.sensors.poll()
  File "/usr/local/lib/python3.9/dist-packages/pypilot/sensors.py", line 391, in poll
    self.signalk.poll()
  File "/usr/local/lib/python3.9/dist-packages/pypilot/signalk.py", line 327, in poll
    self.sensors.write(sensor, data, 'signalk')
  File "/usr/local/lib/python3.9/dist-packages/pypilot/sensors.py", line 418, in write
    self.sensors[sensor].write(data, source)
  File "/usr/local/lib/python3.9/dist-packages/pypilot/sensors.py", line 45, in write
    if not self.update(data):
  File "/usr/local/lib/python3.9/dist-packages/pypilot/sensors.py", line 219, in update
    self.speed.set(data['speed'])
KeyError: 'speed'
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python3.9/multiprocessing/popen_fork.py", line 27, in poll
    pid, sts = os.waitpid(self.pid, flag)
  File "/usr/local/lib/python3.9/dist-packages/pypilot/autopilot.py", line 193, in cleanup
    raise KeyboardInterrupt # to get backtrace on all processes
KeyboardInterrupt
Thanks for reporting this.   It seems that the issue is,  gpsd somehow disconnects from pypilot and pypilot instead tries to get gps data from signalk which is causing the issue.

It is strange because it should hit the break line 449 on signalk.py if gps speed is not reported by signalk and therefore not update the sensor but somehow it did?

I will try to reproduce this.    You are getting gpsd into signalk correct?   I need to reproduce it, but I think it only happens with this particular configuration.
Reply
#37
openplotter-serial v4 beta fixes issues with gpsd conf and it should also fix this issue (gpsd stealing gps)
Reply
#38
(2024-04-20, 07:09 PM)Sailoog Wrote: openplotter-serial v4 beta fixes issues with gpsd conf and it should also fix this issue (gpsd stealing gps)

re enabled & started gpsd again & everything  seems fine both with pypilot running in terminal and openplotter app  Cool Cool
Reply
#39
(2024-04-20, 07:09 PM)Sailoog Wrote: openplotter-serial v4 beta fixes issues with gpsd conf and it should also fix this issue (gpsd stealing gps)

Can you point me to documentation for openplotter-serial?
Reply
#40
https://openplotter.readthedocs.io/en/3....l_app.html

there are small differences with version 4.x.x but that should help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)