From 3e20fe5ca1da13f9f682f489c7721973f3ea54dc Mon Sep 17 00:00:00 2001 From: John Klug Date: Thu, 14 Jan 2021 09:59:40 -0600 Subject: Make baud rate setting reliable, and save gpsd reboot test --- recipes-navigation/gpsd/gpsd/gpsd-default | 53 ++++++++++++++++++++------ recipes-navigation/gpsd/test/README | 10 +++++ recipes-navigation/gpsd/test/gpsd-test.tar.gz | Bin 0 -> 712 bytes 3 files changed, 52 insertions(+), 11 deletions(-) create mode 100644 recipes-navigation/gpsd/test/README create mode 100644 recipes-navigation/gpsd/test/gpsd-test.tar.gz diff --git a/recipes-navigation/gpsd/gpsd/gpsd-default b/recipes-navigation/gpsd/gpsd/gpsd-default index fa67fd1..9bc1eef 100644 --- a/recipes-navigation/gpsd/gpsd/gpsd-default +++ b/recipes-navigation/gpsd/gpsd/gpsd-default @@ -52,6 +52,7 @@ GPSFIX="3" # should not need to change the baud rate. # function SET_GPS_SPEED { + if [[ $(mts-io-sysfs show hw-version) =~ ^MTHS- ]] ; then if gpsctl -t 'u-blox' -D 5 -x '\x06\x41\x00\x00\x03\x1F\x90\x47\x4F\xB1\xFF\xFF\xEA\xFF' $GPS_LINE ; then logger -s -t 'gpsd info' -p daemon.info "GPS LNA set high" @@ -60,17 +61,47 @@ if [[ $(mts-io-sysfs show hw-version) =~ ^MTHS- ]] ; then fi fi +((maxtries = 10)) if [[ $(cat /run/config/gpstype) == u-blox ]] ; then - # Set the baud rate. Works better with ntp at a higher baud rate. - if ! gpsctl -T 20 -t 'u-blox' -s $GPS_BAUD -b -f $GPS_LINE ; then - echo 'WARNING: Unable to set GPS serial port speed.' - else - # The next line is needed due to a bug in gpsctl. - # We will go back to the default baud rate if we don't do this step. - echo Expect a timeout error here. Need this error. - gpsctl -T 2 -f $GPS_LINE - stty -F $GPS_LINE $GPS_BAUD - fi -fi # End of U-Blox GPS type + while ((maxtries > 0)) ; do + ((maxtries--)) + if ((maxtries == 5)) ; then + # Not going well, so reset the GPS. + mts-io-sysfs store gnss-reset 0 + usleep 50 + mts-io-sysfs store gnss-reset 1 + sleep 2 + fi # Reset at maxtries == 5 + + # Set the baud rate to default speed if having issues + if ((maxtries < 8)) && ((maxtries % 2 == 1)) ; then + stty -F $GPS_LINE 9600 + fi + + # Set the baud rate. Works better with ntp at a higher baud rate. + if ! gpsctl -T 20 -t 'u-blox' -s $GPS_BAUD -b -f $GPS_LINE ; then + echo 'WARNING: Unable to set GPS serial port speed.' + else + # The next line is needed due to a bug in gpsctl. + # We will go back to the default baud rate if we don't do this step. + echo Expect a timeout error here. Need this error. + gpsctl -T 2 -f $GPS_LINE + stty -F $GPS_LINE $GPS_BAUD + fi + speed=$(stty -F $GPS_LINE speed 2>&1) + if [[ $speed = 115200 ]] ; then + result=$(gpsctl -T 2 -f $GPS_LINE 2>&1) + if [[ $result =~ u-blox[[:space:]]at[[:space:]]115200[[:space:]] ]] ; then + break + fi # gpsctl has a good status + fi # gpsd serial port speed is correct + done # Loop until maxtries + + if ((maxtries == 0)) && [[ -n $result ]] ; then + logger -s -t 'gpsd info' -p daemon.alert "gpsctl -T 2 -f $GPS_LINE" + logger -s -t 'gpsd info' -p daemon.alert "$GPS_LINE: $(stty -F $GPS_LINE speed) baud" + logger -s -t 'gpsd info' -p daemon.alert "$result" + fi # If out of loop with maxtries exhausted, print error +fi # If U-Blox GPS type } diff --git a/recipes-navigation/gpsd/test/README b/recipes-navigation/gpsd/test/README new file mode 100644 index 0000000..18d712f --- /dev/null +++ b/recipes-navigation/gpsd/test/README @@ -0,0 +1,10 @@ +Install the test in the root file system +of a device with ntp and gpsd installed. +ntp must be configured to use gpsd as +the time source. + +cd / +sudo tar -xf /tmp/gpsd-test.tar.gz + +See /usr/share/gpsd-test/README for more +details. diff --git a/recipes-navigation/gpsd/test/gpsd-test.tar.gz b/recipes-navigation/gpsd/test/gpsd-test.tar.gz new file mode 100644 index 0000000..4d74be3 Binary files /dev/null and b/recipes-navigation/gpsd/test/gpsd-test.tar.gz differ -- cgit v1.2.3