CaptainMidnight
Posts: 46
Joined: Sun Nov 03, 2019 4:32 pm

[SOLVED] Uputronics U-blox GPS HAT - fixing HAT and GPSD service baud rate to 115200 on power up / reboot?

Fri Dec 13, 2019 11:55 pm

Been using a RPi4B with a GPS HAT - the u-blox from Uputronics, nicely configured and working well with just a few finishing touches to clear up.

The 1st and biggest bug bear is trying to force the serial baud rate that the gpsd service uses.

I can setup the baud rate via the command line as follows and it just works: -

Code: Select all

sudo service gpsd stop
sudo /bin/stty -F /dev/ttyAMA0 ispeed 115200 ospeed 115200
sudo /usr/bin/gpsctx --port /dev/serial0 -b 115200 -B 115200
sudo /usr/bin/gpsctx --port /dev/serial0 -b 115200 --nmea yes 
sudo /usr/bin/gpsctlx --port /dev/serial0 -b 115200 --save_config 
sudo service gpsd start
'gpsctlx' - this is just a different version of gpsctl than the one that's already installed and works 100% as expected - it sets the baud rate on the HAT to 115200 and saves it to the HAT's configuration - all works fine with the gpsd service at the command line doing it manually.

But, if this config is added to say rc.local after reboots, it seems that the gpsd service randomly chooses to default to trying to use a baud rate of 9600?

Is there any other, or more reliable way, of forcing the gpsd service to always be fixed to using only 115200 as the serial baud rate - can't see it as a gpsd service option, unless I'm looking in the wrong pkaces?
Last edited by CaptainMidnight on Wed Dec 25, 2019 8:09 pm, edited 1 time in total.
"Never get out of the boat." Absolutely goddamn right!
Unless you were goin' all the way...

trejan
Posts: 1203
Joined: Tue Jul 02, 2019 2:28 pm

Re: Uputronics U-blox GPS HAT - fixing HAT and GPSD service baud rate to 115200 on power up / reboot?

Sat Dec 14, 2019 12:06 am

What Raspbian are you running?

You can disable the autobaud feature and force it by using the -s option for gpsd. Add it in /etc/default/gpsd

You don't need the gpsctl commands once you've saved it in the Ublox module. If your GPS HAT is old then you'll need to add a lithium coin cell. Newer ones have a supercap instead.

CaptainMidnight
Posts: 46
Joined: Sun Nov 03, 2019 4:32 pm

Re: Uputronics U-blox GPS HAT - fixing HAT and GPSD service baud rate to 115200 on power up / reboot?

Sat Dec 14, 2019 12:13 am

Latest version - buster.

The HAT is just recent and uses the supercap.

I'll have another look again for the '-s' option, last time all I found was posts/pages saying that I'd have to re-compile gpsd ..... Ok will look again thanks
"Never get out of the boat." Absolutely goddamn right!
Unless you were goin' all the way...

trejan
Posts: 1203
Joined: Tue Jul 02, 2019 2:28 pm

Re: Uputronics U-blox GPS HAT - fixing HAT and GPSD service baud rate to 115200 on power up / reboot?

Sat Dec 14, 2019 12:19 am

CaptainMidnight wrote:
Sat Dec 14, 2019 12:13 am
I'll have another look again for the '-s' option, last time all I found was posts/pages saying that I'd have to re-compile gpsd .....
Uhh. Never mind. The Debian version doesn't have that option. I've got the development version which added -s to set the speed. I didn't realise it was only recently added.

Your best option is probably to alter the systemd unit for gpsd so it runs the stty command before starting gpsd each time. Add something like "ExecStartPre=/usr/bin/stty speed 115200 -F /dev/serial0"

CaptainMidnight
Posts: 46
Joined: Sun Nov 03, 2019 4:32 pm

Re: Uputronics U-blox GPS HAT - fixing HAT and GPSD service baud rate to 115200 on power up / reboot?

Sat Dec 14, 2019 1:03 am

Made the changes to the gpsd.service file, did the daemon reload and now after a reboot the gpsd service starts at the desired baud rate 115200

Many thanks :D
"Never get out of the boat." Absolutely goddamn right!
Unless you were goin' all the way...

philrandal
Posts: 2
Joined: Sun Sep 22, 2019 10:06 am

Re: [SOLVED] Uputronics U-blox GPS HAT - fixing HAT and GPSD service baud rate to 115200 on power up / reboot?

Sat Jan 18, 2020 7:50 pm

I'm late to the discussion, but another possibility is to use gpsctl from my GitHub repo to configure the Uputronics Hat:

http://www.philrandal.co.uk/blog/archiv ... y_213.html

https://github.com/philrandal/gpsctl

And then start gpsd with the -b parameter so it doesn't mess with the U-Blox config.

Cheers,

Phil

CaptainMidnight
Posts: 46
Joined: Sun Nov 03, 2019 4:32 pm

Re: [SOLVED] Uputronics U-blox GPS HAT - fixing HAT and GPSD service baud rate to 115200 on power up / reboot?

Tue Jan 21, 2020 10:39 pm

philrandal wrote:
Sat Jan 18, 2020 7:50 pm
I'm late to the discussion, but another possibility is to use gpsctl from my GitHub repo to configure the Uputronics Hat:

http://www.philrandal.co.uk/blog/archiv ... y_213.html

https://github.com/philrandal/gpsctl

And then start gpsd with the -b parameter so it doesn't mess with the U-Blox config.

Cheers,

Phil
Yeah already have used gpsctl to fix the gps baud rate, will look at the gpsd -b option - more googling required - thanks for that thought, always open to suggestions.

Just currently looking at the gps data output format - I've noticed if it is interpreted as nmea format cgps provides a 1x1x1 metre location fix, if interpreted as U-blox (theoretically default) cgps provides a much looser fix - maybe due to increased gps data processing/interpretation needed........

Out of interest have you been able to successfully fix the gps data output format with gpsctl?
"Never get out of the boat." Absolutely goddamn right!
Unless you were goin' all the way...

Return to “HATs and other add-ons”