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
#1
Struggling here to get Pypilot working with the GPS dongle. 
Serial Ublox is a connection to signalk, cat /dev/ttyOP_gps and the data can been seen coming in.
Code:
pi@openplotter:~ $ cat /dev/ttyOP_gps
$GPRMC,104422.00,A,2746.16364,N,01541.46466,W,0.341,,250324,,,A*61
$GPVTG,,T,,M,0.341,N,0.631,K,A*21
$GPGGA,104422.00,2746.16364,N,01541.46466,W,1,08,1.03,1.3,M,35.5,M,,*42
$GPGSA,A,3,25,29,28,32,31,18,26,16,,,,,2.00,1.03,1.71*0A
$GPGSV,3,1,10,12,04,073,,16,07,273,36,18,31,145,37,25,31,060,34*71
Everything works.
Just the arduino in whitelist >
Code:
pi@openplotter:~ $ cat .pypilot/serial_ports
/dev/ttyOP_pypilot
/dev/serial/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.1.1:1.0-port0

if I start pyilot in systemd > sudo systemctl start pypilot

status >
Code:
pi@openplotter:~ $ sudo systemctl status pypilot
* pypilot.service - pypilot
     Loaded: loaded (/etc/systemd/system/pypilot.service; disabled; preset: enabled)
     Active: active (running) since Mon 2024-03-25 10:46:48 GMT; 7s ago
   Main PID: 4382 (pypilot)
      Tasks: 20 (limit: 1576)
        CPU: 2.711s
     CGroup: /system.slice/pypilot.service
             |-4382 /usr/bin/python3 /usr/local/bin/pypilot
             |-4383 /usr/bin/python3 /usr/local/bin/pypilot
             |-4385 /usr/bin/python3 /usr/local/bin/pypilot
             |-4391 /usr/bin/python3 /usr/local/bin/pypilot
             |-4392 /usr/bin/python3 /usr/local/bin/pypilot
             |-4394 /usr/bin/python3 /usr/local/bin/pypilot
             |-4396 /usr/bin/python3 /usr/local/bin/pypilot
             |-4397 /usr/bin/python3 /usr/local/bin/pypilot
             `-4398 /usr/bin/python3 /usr/local/bin/pypilot

Mar 25 10:46:55 openplotter pypilot[4398]: server add socket ('10.42.0.1', 54048)
Mar 25 10:46:55 openplotter pypilot[4394]: signalk process 4394
Mar 25 10:46:55 openplotter pypilot[4394]: signalkread token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkZXZpY2UiOiJweXBpbG90>
Mar 25 10:46:55 openplotter sudo[4421]:       pi : PWD=/ ; USER=root ; COMMAND=/usr/bin/stty -F /dev/ttyACM0
Mar 25 10:46:55 openplotter sudo[4421]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=1000)
Mar 25 10:46:55 openplotter sudo[4421]: pam_unix(sudo:session): session closed for user root
Mar 25 10:46:55 openplotter pypilot[4394]: signalk server found 127.0.0.1:3000
Mar 25 10:46:55 openplotter pypilot[4382]: sensor found gps gpsd /dev/ttyACM0 Mon Mar 25 10:46:55 2024
Mar 25 10:46:56 openplotter pypilot[4394]: signalk found ws://127.0.0.1:3000/signalk/v1/stream?subscribe=none
Mar 25 10:46:56 openplotter pypilot[4394]: signalk connected to ws://127.0.0.1:3000/signalk/v1/stream?subscribe=none


Code:
pi@openplotter:~ $ journalctl -b  | grep pypilot
Mar 25 09:58:02 openplotter systemd[1]: Started pypilot_web.service - pypilot web.
Mar 25 09:58:16 openplotter pypilot_web[269]: failed to read config /home/pi/.pypilot/web.conf
Mar 25 09:58:16 openplotter pypilot_web[269]: using port 8000
Mar 25 09:58:16 openplotter pypilot_web[269]: processing clients
Mar 25 10:46:48 openplotter sudo[4378]:       pi : TTY=pts/0 ; PWD=/home/pi ; USER=root ; COMMAND=/usr/bin/systemctl start pypilot
Mar 25 10:46:48 openplotter systemd[1]: Started pypilot.service - pypilot.
Mar 25 10:46:49 openplotter pypilot[4382]: autopilot start 2911.835676912
Mar 25 10:46:49 openplotter pypilot[4382]: world magnetic model not available
Mar 25 10:46:49 openplotter pypilot[4385]: imu process 4385
Mar 25 10:46:49 openplotter pypilot[4391]: nmea process 4391
Mar 25 10:46:49 openplotter pypilot[4391]: listening on port 20220 for nmea connections
Mar 25 10:46:49 openplotter pypilot[4385]: made imu process realtime
Mar 25 10:46:49 openplotter pypilot[4385]: Using settings file RTIMULib.ini
Mar 25 10:46:49 openplotter pypilot[4385]: Settings file not found. Using defaults and creating settings file
Mar 25 10:46:49 openplotter pypilot[4385]: Failed to open settings file for saveFailed to open SPI bus 0, select 0
Mar 25 10:46:49 openplotter pypilot[4385]: Using fusion algorithm Kalman STATE4
Mar 25 10:46:49 openplotter pypilot[4382]: loading servo calibration /home/pi/.pypilot/servocalibration
Mar 25 10:46:49 openplotter pypilot[4382]: WARNING: using default servo calibration!!
Mar 25 10:46:49 openplotter pypilot[4396]: gps process 4396
Mar 25 10:46:49 openplotter pypilot[4382]: Available Pilots: ['absolute', 'basic']
Mar 25 10:46:49 openplotter pypilot[4398]: pypilotServer process 4398
Mar 25 10:46:49 openplotter pypilot[4382]: pypilotinit complete 2912.076193986
Mar 25 10:46:49 openplotter pypilot[4382]: serialprobe removing gps device /dev/serial/by-id/usb-u-blox_AG_-_www.u-blox.com_u-blox_7_-_GPS_GNSS_Receiver-if00
Mar 25 10:46:49 openplotter pypilot[4382]: servo probe ('/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0', 38400) 2912.134809615
Mar 25 10:46:49 openplotter pypilot[4382]: server/client is running too _slowly_ 0.08476174100042044
Mar 25 10:46:49 openplotter pypilot[4382]: sensor found wind tcp IIsocket0 Mon Mar 25 10:46:49 2024
Mar 25 10:46:49 openplotter pypilot[4398]: load file /home/pi/.pypilot/pypilot.conf
Mar 25 10:46:49 openplotter pypilot[4398]: store_file /home/pi/.pypilot/pypilot.conf.bak 2912.220 False
Mar 25 10:46:49 openplotter pypilot[4398]: server setup has 6 pipes
Mar 25 10:46:49 openplotter pypilot[4391]: reset gps timeoffset 19807 38808 1711363609.6412442
Mar 25 10:46:49 openplotter pypilot[4382]: sensor found gps tcp GPsocket0 Mon Mar 25 10:46:49 2024
Mar 25 10:46:49 openplotter pypilot[4385]: imu rate set to rate 20
Mar 25 10:46:49 openplotter pypilot[4385]: imu rate set to rate 20
Mar 25 10:46:49 openplotter pypilot[4385]: setting initial gyro bias [0.71, -0.39, 0.25]
Mar 25 10:46:49 openplotter pypilot[4398]: server add socket ('10.42.0.1', 54042)
Mar 25 10:46:49 openplotter pypilot[4398]: server add socket ('10.42.0.59', 57144)
Mar 25 10:46:50 openplotter pypilot[4398]: zeroconf addresses ['127.0.0.1', '10.42.0.1'] 2
Mar 25 10:46:50 openplotter pypilot[4382]: arduino servo found ['/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0', 38400]
Mar 25 10:46:50 openplotter pypilot[4382]: serialprobe success: /home/pi/.pypilot/servodevice ['/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0', 38400]
Mar 25 10:46:50 openplotter pypilot[4392]: signalk zeroconf service add openplotter._http._tcp.local. _http._tcp.local.
Mar 25 10:46:50 openplotter pypilot[4392]: signalk zeroconf service add openplotter._http._tcp.local. _http._tcp.local.
Mar 25 10:46:50 openplotter pypilot[4397]: gps filter process 4397
Mar 25 10:46:51 openplotter pypilot[4396]: gpsd connected
Mar 25 10:46:54 openplotter pypilot[4382]: sensors is running too _slowly_ 0.04601940700013074
Mar 25 10:46:54 openplotter pypilot[4382]: GPSD devices ['/dev/ttyACM0']
Mar 25 10:46:54 openplotter pypilot[4383]: calibration loaded, starting 4383
Mar 25 10:46:55 openplotter pypilot[4398]: server remove socket ('10.42.0.1', 54042)
Mar 25 10:46:55 openplotter pypilot[4398]: server add socket ('10.42.0.1', 54048)
Mar 25 10:46:55 openplotter pypilot[4394]: signalk process 4394
Mar 25 10:46:55 openplotter pypilot[4394]: signalkread token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkZXZpY2UiOiJweXBpbG90LTc1MTMzNjYyMTg3IiwiaWF0IjoxNzExMjE2NjY5LCJleHAiOjE3NDI3NzQyNjl9.vOLb9_B8_TzLmfGlT-xKHAtzAvrEaYyqaoPV8Pqolb4
Mar 25 10:46:55 openplotter pypilot[4394]: signalk server found 127.0.0.1:3000
Mar 25 10:46:55 openplotter pypilot[4382]: sensor found gps gpsd /dev/ttyACM0 Mon Mar 25 10:46:55 2024
Mar 25 10:46:55 openplotter sudo[4423]:       pi : TTY=pts/0 ; PWD=/home/pi ; USER=root ; COMMAND=/usr/bin/systemctl status pypilot
Mar 25 10:46:56 openplotter pypilot[4394]: signalk found ws://127.0.0.1:3000/signalk/v1/stream?subscribe=none
Mar 25 10:46:56 openplotter pypilot[4394]: signalk connected to ws://127.0.0.1:3000/signalk/v1/stream?subscribe=none
Mar 25 10:46:57 openplotter pypilot[4382]: nmea probe ('/dev/serial/by-id/usb-1a86_USB2.0-Ser_-if00-port0', 38400)
Mar 25 10:47:01 openplotter pypilot[4398]: server remove socket ('10.42.0.1', 54048)
Mar 25 10:47:01 openplotter pypilot[4398]: server add socket ('10.42.0.1', 47904)
Mar 25 10:47:02 openplotter pypilot[4382]: nmea probe ('/dev/serial/by-id/usb-1a86_USB2.0-Ser_-if00-port0', 4800)
Mar 25 10:47:02 openplotter pypilot[4382]: failed to open ('/dev/serial/by-id/usb-1a86_USB2.0-Ser_-if00-port0', 4800) for nmea data [Errno 16] could not open port /dev/serial/by-id/usb-1a86_USB2.0-Ser_-if00-port0: [Errno 16] Device or resource busy: '/dev/serial/by-id/usb-1a86_USB2.0-Ser_-if00-port0'
Mar 25 10:47:05 openplotter pypilot[4382]: sensor lost gps gpsd /dev/ttyACM0 Mon Mar 25 10:47:05 2024
Mar 25 10:47:11 openplotter pypilot[4398]: server remove socket ('10.42.0.1', 47904)
Mar 25 10:47:11 openplotter pypilot[4398]: server add socket ('10.42.0.1', 41396)
Mar 25 10:47:13 openplotter pypilot[4382]: sensor lost truewind gps+wind None Mon Mar 25 10:47:13 2024
Mar 25 10:47:19 openplotter pypilot[4382]: nmea probe ('/dev/serial/by-id/usb-1a86_USB2.0-Ser_-if00-port0', 38400)
Mar 25 10:47:19 openplotter pypilot[4382]: failed to open ('/dev/serial/by-id/usb-1a86_USB2.0-Ser_-if00-port0', 38400) for nmea data [Errno 16] could not open port /dev/serial/by-id/usb-1a86_USB2.0-Ser_-if00-port0: [Errno 16] Device or resource busy: '/dev/serial/by-id/usb-1a86_USB2.0-Ser_-if00-port0'
Mar 25 10:47:19 openplotter pypilot[4382]: nmea probe ('/dev/serial/by-id/usb-1a86_USB2.0-Ser_-if00-port0', 4800)
Mar 25 10:47:19 openplotter pypilot[4382]: failed to open ('/dev/serial/by-id/usb-1a86_USB2.0-Ser_-if00-port0', 4800) for nmea data [Errno 16] could not open port /dev/serial/by-id/usb-1a86_USB2.0-Ser_-if00-port0: [Errno 16] Device or resource busy: '/dev/serial/by-id/usb-1a86_USB2.0-Ser_-if00-port0'
Mar 25 10:47:21 openplotter pypilot[4398]: server remove socket ('10.42.0.1', 41396)
Mar 25 10:47:22 openplotter pypilot[4398]: server add socket ('10.42.0.1', 48894)

Now signalk can't see the gps anymore and >
Code:
pi@openplotter:~ $ cat /dev/ttyOP_gps
cat: /dev/ttyOP_gps: Device or resource busy
Need to reboot to get it back.

Signalk has a connection to tcp 20220 & opencpn sees a position but not stable.

What should I do??? 

Thanks Heart
Reply
#2
I think what I see is that it's the gpsd (gps daemon) that 'steals' the gps device, and the pypilot creates a connection to the GPS daemon. Which sounds like a proper marriage. You might want to have signalk create a simlar connection to this daemon, like below.

[Image: 316647777-c5b11f9a-2866-4e00-bcdd-bb4e98...=197609618]
Reply
#3
(2024-03-25, 09:40 PM)ironman Wrote: I think what I see is that it's the gpsd (gps daemon) that 'steals' the gps device, and the pypilot creates a connection to the GPS daemon. Which sounds like a proper marriage. You might want to have signalk create a simlar connection to this daemon, like below.

[Image: 316647777-c5b11f9a-2866-4e00-bcdd-bb4e98...=197609618]
Thanks. Can't see your image though..

Not sure what gpsd port to add. Seems odd that pypilot is probing tty with a white list only containing the arduino?? 

it's close though, I can feel it  Big Grin Big Grin
Reply
#4
Sorry about that, here it is. I cannot show images without them blowing up XXL-size, annoys the hell out of me.

So I just checked it myself and it appears as if the gps daemon kicks in the moment it is woken up by some other process connecting to port 2947. SignalK can do that when you make a connection as below; pypilot does the same. The moment gps daemon wakes up, it hogs the ublox, preventing you from catting the device. But the good news is, from that point on, the gps information is available on port 2947 on the localhost. You cannot access it on the lan interface though.


Attached Files Image(s)
   
Reply
#5
Thnx, that works but but unstable, opencpn gets a position most of the time. Not sure it's the way to go though. Maybe next will try putting every path i can find in the blacklist apart from the arduino
Reply
#6
Check with lsof which process has the port open.
Reply
#7
This might be caused by your pi being set up as both access point and wifi client, like openplotter encourages. Disconnect any wifi client. On my boat, I used to connect openplotter to the marina wifi to update charts, buoy layers etc. Always had vague connectivity based troubles in the berth that vanished when I left the harbour. These problems got away when I got into the habit of connecting to my phone's wifi hotspot instead, that I switched off after the update.

Not until recently, helping out a friend with connecting up his ublox, did we isolate this as the sole cause, and did I realize what had me pull my hair out in the past.
Reply
#8
Might have solved it, disabled & stopped GPSD in systemd & gps connection in signalk stays live now when pypilot is running.

Though something restarted it just now,, nearly there though!!
Reply
#9
Yeah, but then you probably rely on pypilot connecting to the gps and relaying it to signalk. That's not what an autopilot is for. Can you show me what the Data Browser looks like?

Try again: enable and start gpsd, signalk configured as above and restart, forget all wifi connections in openplotter, pypilot and opencpn down for now. Can you confirm my suspicion that you have both access point and wifi client active on your pi now?

syslog should say:

Quote:syslog:Mar 26 09:05:06 openplotter gpsdctl: gpsd_control(action=add, arg=/dev/ttyACM0)
syslog:Mar 26 09:05:06 openplotter gpsdctl: reached a running gpsd


signalk log should say:

Quote:Mar 26 09:18:30 2024-03-26T09:18:30.803Z signalkConfusedtreams:gpsd Socket connected.


data browser should say:


Attached Files Image(s)
   
Reply
#10
(2024-03-26, 09:55 AM)ironman Wrote: Yeah, but then you probably rely on pypilot connecting to the gps and relaying it to signalk.
Seems OK with the gps connected to signalk, but with gpds disabled pypilot still gets nav data from signalk but the gps connection to signalk remains up. 
Another issue  - when starting pypilot from systemd it doesn't find the IMU which is on i2c6, not i2c1. Works from a terminal with  .pypilot/RTIMULib.ini set to >
# I2C Bus (between 0 and 7)
I2CBus=6
Does systemd start pypilot from another directory &  RTIMULib.ini?

tnx

Oops, spoke too soon, something has started gpsd in systemd despite it and gpsd.socked being disabled....

pi@openplotter:~ $ sudo systemctl status gpsd.socket
* gpsd.socket - GPS (Global Positioning System) Daemon Sockets
Loaded: loaded (/lib/systemd/system/gpsd.socket; disabled; preset: enabled)
Active: active (running) since Tue 2024-03-26 09:36:01 GMT; 9min ago
Triggers: * gpsd.service
Listen: /run/gpsd.sock (Stream)
[::1]:2947 (Stream)
127.0.0.1:2947 (Stream)
Tasks: 0 (limit: 1576)
CPU: 2ms
CGroup: /system.slice/gpsd.socket

Mar 26 09:36:01 openplotter systemd[1]: Listening on gpsd.socket - GPS (Global Positioning System) Daemon Sockets
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)