Cruisers Forum
 


Reply
  This discussion is proudly sponsored by:
Please support our sponsors and let them know you heard about their products on Cruisers Forums. Advertise Here
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 13-10-2020, 12:45   #1
Registered User

Join Date: Mar 2020
Location: Nieuwpoort Belgium
Boat: Comar Comet 910
Posts: 49
Raspberry Pi 4 and OpenCPN

Hopefully this,is the right place for this question.


After every restart on my Raspberry Pi 4 I have to reinitialize the USB GPS module for OpenCPN to recognize it.


Following commands are needed, ref.: https://www.zwiebelfam.nl/een-gps-tr...-de-raspberry/


pi@raspberrypi ~ $ sudo systemctl stop gpsd.socket
pi@raspberrypi ~ $ sudo systemctl disable gpsd.socket


These are needed to free the listening to USB port listening

And this one to let gpsd know that a GPS device is available on a USB port:


pi@raspberrypi:~$ sudo gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock

My question is how to include these commands in a service so that at startup these are executed automatically.
brice3010 is offline   Reply With Quote
Old 13-10-2020, 13:55   #2
Registered User

Join Date: Sep 2011
Location: Montreal
Boat: Fountaine Pajot / Venezia 42
Posts: 147
Re: Raspberry Pi 4 and OpenCPN

Quote:
Originally Posted by brice3010 View Post
Hopefully this,is the right place for this question.


After every restart on my Raspberry Pi 4 I have to reinitialize the USB GPS module for OpenCPN to recognize it.


Following commands are needed, ref.: https://www.zwiebelfam.nl/een-gps-tr...-de-raspberry/


pi@raspberrypi ~ $ sudo systemctl stop gpsd.socket
pi@raspberrypi ~ $ sudo systemctl disable gpsd.socket


These are needed to free the listening to USB port listening

And this one to let gpsd know that a GPS device is available on a USB port:


pi@raspberrypi:~$ sudo gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock

My question is how to include these commands in a service so that at startup these are executed automatically.

I am going to guess. As I have no experience with gpsd. But I have been a UNIX sysadmin for more than 25 years or so. I know, Linux (with systemd) is different.


if -F fixes you issues, and according to the man page it creates a control socket for device addition and removal commands, than my recommandation to you is

  1. if you have a config file, you can add it there to GPSD_OPTIONS variable, and at startup, the system will execute it.
  2. or if you are not sure, you can edit your systemd service file (should be somewhere like /usr/lib/systemd/system/gpsd.service) and add it to the variable ExecStart
    something like:
    ExecStart=/usr/sbin/gpsd $GPSD_OPTIONS /dev/ttyUSB0 -F /var/run/gpsd.sock


BTW, when you disable a service, it will not start the next time your start or restart your system. It will remain disabled until you explicitly enable it and start it (or restart your system after enabling it)



Good luck
scargo is offline   Reply With Quote
Old 13-10-2020, 15:04   #3
Registered User

Join Date: Aug 2009
Location: oriental
Boat: crowther trimaran 33
Posts: 4,417
Re: Raspberry Pi 4 and OpenCPN

gpsd is.... well...


You should probably not pass the serial port to gpsd especially if using a control socket


Instead just use gpsdctl add /dev/ttyUSB0


It's recommended to write udev rules to do this for you and it can add and remove the gpsd device automatically at boot as well as while running. This basically solves the issues from what I can tell.
seandepagnier is offline   Reply With Quote
Old 13-10-2020, 22:26   #4
Registered User

Join Date: Mar 2020
Location: Nieuwpoort Belgium
Boat: Comar Comet 910
Posts: 49
Re: Raspberry Pi 4 and OpenCPN

Thank you very much for your replies scargo and seandepagnier. Reading your replies I realise that a bit more context would be useful.


Following contents is present:


/lib/systemd/system/gpsd.service shows:


[Unit]
Description=GPS (Global Positioning System) Daemon
Requires=gpsd.socket
After=chronyd.service


[Service]
Type=forking
EnvironmentalFile=-/etc/default/gpsd
ExecStart=/usr/sbin/gpsd $GPSD_OPTIONS $DEVICES


[Install]
WantedBy=multi-user.target
Also=gpsd.socket




Also: /usr/sbin/gpsd when opened in nano contains a lot of "garbage" and "is not writeable".


/etc/default/gpsd contains:


START_DAEMON="true"
USBAUTO="true"
DEVICES="dev/ttyACM0"
GPSD_OPTIONS="-n -b"
GPSD_SOCKET="/var/run/gpsd.sock"


I left the comments out from the contents above.


Somehow, using ttyACM0 works to get the GPS signals in my system; ttyUSB0 is not used (I think).


Now from the above, would you coroborate that your replies are still valid?
brice3010 is offline   Reply With Quote
Old 14-10-2020, 01:20   #5
Registered User

Join Date: Mar 2020
Location: Nieuwpoort Belgium
Boat: Comar Comet 910
Posts: 49
Re: Raspberry Pi 4 and OpenCPN

Reading this post https://www.raspberrypi.org/forums/v...c.php?t=138711 I opened /lib/systemd/system/gpsd.socket and found this:


[Unit]
Description=GPS (Global Positioning System) Daemon Sockets


[Socket]


ListenStream=/var/run/gpsd.sock
ListenStream=[::1]:2947
ListenStream=0.0.0.1:2947
SockeMode=0600


[Install]
WantedBy=sockets.target




Surprised by the address 0.0.0.1:2947 I changed that to 0.0.0.0:2947


After hard reboot the GPS was read properly by OpenCPN. Not quite sure how this wrong localhost address could have been programmed... ?
brice3010 is offline   Reply With Quote
Reply

Tags
enc, opencpn


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
General Question to Raspberry OpenCPN and OpenGL kutt OpenCPN 27 02-03-2018 09:38
OpenCPN on Raspberry Pi 2 and plugins Andreas29 OpenCPN 5 31-12-2015 04:25
OpenCPN plugin and raspberry Neitsabes OpenCPN 15 31-05-2015 14:39
Comproblem on Raspberry Pi and OpenCPN vagspel OpenCPN 4 26-12-2012 05:01
Raspberry Pi and OpenCPN 3.1.915 spillemw OpenCPN 20 24-09-2012 02:30

Advertise Here


All times are GMT -7. The time now is 19:30.


Google+
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Social Knowledge Networks
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.

ShowCase vBulletin Plugins by Drive Thru Online, Inc.