Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"ERROR: EPO in NVRAM doesnt match file" #15

Open
bclaymiles opened this issue Jan 17, 2023 · 16 comments
Open

"ERROR: EPO in NVRAM doesnt match file" #15

bclaymiles opened this issue Jan 17, 2023 · 16 comments

Comments

@bclaymiles
Copy link

I keep getting this error, but I can't figure out why. Sometimes, just 'pushing' one or two fewer EPO sets will get it to go through cleanly. But run from cron daily, this happens frequently, and limits the utility of doing so in an automated fashion.

I call epoloader from a simple shell wrapper. The issue happens whether via cron or direct on command line. Here's the wrapper. I've also slightly modified eporetrieve to write to /var/tmp rather than /tmp.

#!/bin/bash
LAT="xxxxx"
LON="-xxxxx"
ALT="41"
SPEED="115200"
DEV="/dev/gpsd0"
FILE="/var/tmp/EPO.DAT"
MAXSETS="26"
nice /usr/local/bin/eporetrieve
/bin/systemctl stop gpsd
stty -F ${DEV} raw 115200 cs8 clocal -cstopb
nice /usr/local/bin/gpssend clear_epo ${DEV}
nice /usr/local/bin/epoloader -s ${SPEED} --no-init -k --max-sets=${MAXSETS} -l=${LAT},${LON},${ALT} -t- ${FILE} ${DEV}
/bin/systemctl start gpsd

I changed the '-l' instantiation to '-l=' having just read the other issue that's up here. No change. I used the 'gpssend clear_epo' as a separate command just for my own clarity; results are no different if I declare it on the epoloader command line.

I would entertain the idea that I'm doing something wrong - although the fact it works fine sometimes seems to suggest otherwise. Oh, and I run the job at 18:03 PST, which is 02:03 UTC, which I presume is early enough in the day to not be a problem.

Here's the full output of the script:

root@ B-NTPsec: ~ # update-epo
EPO data saved to /var/tmp/EPO.DAT
Opening EPO Type II file with 120 sets
GPS Version: ['PMTK705', 'AXN_2.31_3339_13101700', '5632', 'PA6H', '1.0']
Setting known values: xxxx,-xxxx,41 2023,01,17,02,56,50
Time set
Location set
Setting binary mode, speed: 115200
Sending 26 EPO sets of 120
Sending set 1. Valid from 2023-01-16 23:59:46 UTC
Sending set 2. Valid from 2023-01-17 05:59:46 UTC
Sending set 3. Valid from 2023-01-17 11:59:46 UTC
Sending set 4. Valid from 2023-01-17 17:59:46 UTC
Sending set 5. Valid from 2023-01-17 23:59:46 UTC
Sending set 6. Valid from 2023-01-18 05:59:46 UTC
Sending set 7. Valid from 2023-01-18 11:59:46 UTC
Sending set 8. Valid from 2023-01-18 17:59:46 UTC
Sending set 9. Valid from 2023-01-18 23:59:46 UTC
Sending set 10. Valid from 2023-01-19 05:59:46 UTC
Sending set 11. Valid from 2023-01-19 11:59:46 UTC
Sending set 12. Valid from 2023-01-19 17:59:46 UTC
Sending set 13. Valid from 2023-01-19 23:59:46 UTC
Sending set 14. Valid from 2023-01-20 05:59:46 UTC
Sending set 15. Valid from 2023-01-20 11:59:46 UTC
Sending set 16. Valid from 2023-01-20 17:59:46 UTC
Sending set 17. Valid from 2023-01-20 23:59:46 UTC
Sending set 18. Valid from 2023-01-21 05:59:46 UTC
Sending set 19. Valid from 2023-01-21 11:59:46 UTC
Sending set 20. Valid from 2023-01-21 17:59:46 UTC
Sending set 21. Valid from 2023-01-21 23:59:46 UTC
Sending set 22. Valid from 2023-01-22 05:59:46 UTC
Sending set 23. Valid from 2023-01-22 11:59:46 UTC
Sending set 24. Valid from 2023-01-22 17:59:46 UTC
Sending set 25. Valid from 2023-01-22 23:59:46 UTC
Sending set 26. Valid from 2023-01-23 05:59:46 UTC
26 sets sent. Valid from 2023-01-16 23:59:46 to 2023-01-23 11:59:46 UTC
ERROR: EPO in NVRAM doesnt match file
In NVRAM: 2023-01-16 23:59:46 to 2023-01-22 17:59:46 UTC
root@ B-NTPsec: ~ #

Any help would be appreciated, I'm stumped.

@gtjoseph
Copy link
Owner

Hmmm. I'm pretty sure it's not you. :)

  • What's the output of epoinfo?
  • If you retrieve a file, and load that same file several times, will it fail sometimes and work others or does it either always fail, or always work?
  • What happens if you always just send 12 sets?
  • What happens if you lower the baud rate to 57600?

@bclaymiles
Copy link
Author

bclaymiles commented Jan 19, 2023

It decided to behave while I tested again, so I had to force it to fail by using too many sets. The whole process fails if I try 57600. Interestingly, sending twelve sets fails the same as 28 sets (or most other counts).

Force fail, too many sets:

root@ B-NTPsec: /usr/local/bin # update-epo
EPO data saved to /var/tmp/EPO.DAT
Opening EPO Type II file with 120 sets
GPS Version:  ['PMTK705', 'AXN_2.31_3339_13101700', '5632', 'PA6H', '1.0']
Setting known values: 38.xxx,-122.xxx,41  2023,01,19,04,04,14
Time set
Location set
Clearing existing EPO data
Setting binary mode, speed: 115200
Sending 28 EPO sets of 120
Sending set    1.  Valid from 2023-01-18 23:59:46 UTC
Sending set    2.  Valid from 2023-01-19 05:59:46 UTC
Sending set    3.  Valid from 2023-01-19 11:59:46 UTC
Sending set    4.  Valid from 2023-01-19 17:59:46 UTC
Sending set    5.  Valid from 2023-01-19 23:59:46 UTC
Sending set    6.  Valid from 2023-01-20 05:59:46 UTC
Sending set    7.  Valid from 2023-01-20 11:59:46 UTC
Sending set    8.  Valid from 2023-01-20 17:59:46 UTC
Sending set    9.  Valid from 2023-01-20 23:59:46 UTC
Sending set   10.  Valid from 2023-01-21 05:59:46 UTC
Sending set   11.  Valid from 2023-01-21 11:59:46 UTC
Sending set   12.  Valid from 2023-01-21 17:59:46 UTC
Sending set   13.  Valid from 2023-01-21 23:59:46 UTC
Sending set   14.  Valid from 2023-01-22 05:59:46 UTC
Sending set   15.  Valid from 2023-01-22 11:59:46 UTC
Sending set   16.  Valid from 2023-01-22 17:59:46 UTC
Sending set   17.  Valid from 2023-01-22 23:59:46 UTC
Sending set   18.  Valid from 2023-01-23 05:59:46 UTC
Sending set   19.  Valid from 2023-01-23 11:59:46 UTC
Sending set   20.  Valid from 2023-01-23 17:59:46 UTC
Sending set   21.  Valid from 2023-01-23 23:59:46 UTC
Sending set   22.  Valid from 2023-01-24 05:59:46 UTC
Sending set   23.  Valid from 2023-01-24 11:59:46 UTC
Sending set   24.  Valid from 2023-01-24 17:59:46 UTC
Sending set   25.  Valid from 2023-01-24 23:59:46 UTC
Sending set   26.  Valid from 2023-01-25 05:59:46 UTC
Sending set   27.  Valid from 2023-01-25 11:59:46 UTC
Sending set   28.  Valid from 2023-01-25 17:59:46 UTC
  28 sets sent.  Valid from 2023-01-18 23:59:46 to 2023-01-25 23:59:46 UTC
ERROR: EPO in NVRAM doesnt match file
  In NVRAM: 2023-01-18 23:59:46 to 2023-01-24 23:59:46 UTC

epoinfo out:

root@ B-NTPsec: /usr/local/bin # epoinfo /var/tmp/EPO.DAT
Opening EPO Type II file
Set:    1.  GPS Wk: 2245  Hr:  96  Sec:  345600  2023-01-18 23:59:46 to 2023-01-19 05:59:46 UTC
Set:    2.  GPS Wk: 2245  Hr: 102  Sec:  367200  2023-01-19 05:59:46 to 2023-01-19 11:59:46 UTC
Set:    3.  GPS Wk: 2245  Hr: 108  Sec:  388800  2023-01-19 11:59:46 to 2023-01-19 17:59:46 UTC
Set:    4.  GPS Wk: 2245  Hr: 114  Sec:  410400  2023-01-19 17:59:46 to 2023-01-19 23:59:46 UTC
Set:    5.  GPS Wk: 2245  Hr: 120  Sec:  432000  2023-01-19 23:59:46 to 2023-01-20 05:59:46 UTC
Set:    6.  GPS Wk: 2245  Hr: 126  Sec:  453600  2023-01-20 05:59:46 to 2023-01-20 11:59:46 UTC
Set:    7.  GPS Wk: 2245  Hr: 132  Sec:  475200  2023-01-20 11:59:46 to 2023-01-20 17:59:46 UTC
Set:    8.  GPS Wk: 2245  Hr: 138  Sec:  496800  2023-01-20 17:59:46 to 2023-01-20 23:59:46 UTC
Set:    9.  GPS Wk: 2245  Hr: 144  Sec:  518400  2023-01-20 23:59:46 to 2023-01-21 05:59:46 UTC
Set:   10.  GPS Wk: 2245  Hr: 150  Sec:  540000  2023-01-21 05:59:46 to 2023-01-21 11:59:46 UTC
Set:   11.  GPS Wk: 2245  Hr: 156  Sec:  561600  2023-01-21 11:59:46 to 2023-01-21 17:59:46 UTC
Set:   12.  GPS Wk: 2245  Hr: 162  Sec:  583200  2023-01-21 17:59:46 to 2023-01-21 23:59:46 UTC
Set:   13.  GPS Wk: 2246  Hr:   0  Sec:       0  2023-01-21 23:59:46 to 2023-01-22 05:59:46 UTC
Set:   14.  GPS Wk: 2246  Hr:   6  Sec:   21600  2023-01-22 05:59:46 to 2023-01-22 11:59:46 UTC
Set:   15.  GPS Wk: 2246  Hr:  12  Sec:   43200  2023-01-22 11:59:46 to 2023-01-22 17:59:46 UTC
Set:   16.  GPS Wk: 2246  Hr:  18  Sec:   64800  2023-01-22 17:59:46 to 2023-01-22 23:59:46 UTC
Set:   17.  GPS Wk: 2246  Hr:  24  Sec:   86400  2023-01-22 23:59:46 to 2023-01-23 05:59:46 UTC
Set:   18.  GPS Wk: 2246  Hr:  30  Sec:  108000  2023-01-23 05:59:46 to 2023-01-23 11:59:46 UTC
Set:   19.  GPS Wk: 2246  Hr:  36  Sec:  129600  2023-01-23 11:59:46 to 2023-01-23 17:59:46 UTC
Set:   20.  GPS Wk: 2246  Hr:  42  Sec:  151200  2023-01-23 17:59:46 to 2023-01-23 23:59:46 UTC
Set:   21.  GPS Wk: 2246  Hr:  48  Sec:  172800  2023-01-23 23:59:46 to 2023-01-24 05:59:46 UTC
Set:   22.  GPS Wk: 2246  Hr:  54  Sec:  194400  2023-01-24 05:59:46 to 2023-01-24 11:59:46 UTC
Set:   23.  GPS Wk: 2246  Hr:  60  Sec:  216000  2023-01-24 11:59:46 to 2023-01-24 17:59:46 UTC
Set:   24.  GPS Wk: 2246  Hr:  66  Sec:  237600  2023-01-24 17:59:46 to 2023-01-24 23:59:46 UTC
Set:   25.  GPS Wk: 2246  Hr:  72  Sec:  259200  2023-01-24 23:59:46 to 2023-01-25 05:59:46 UTC
Set:   26.  GPS Wk: 2246  Hr:  78  Sec:  280800  2023-01-25 05:59:46 to 2023-01-25 11:59:46 UTC
Set:   27.  GPS Wk: 2246  Hr:  84  Sec:  302400  2023-01-25 11:59:46 to 2023-01-25 17:59:46 UTC
Set:   28.  GPS Wk: 2246  Hr:  90  Sec:  324000  2023-01-25 17:59:46 to 2023-01-25 23:59:46 UTC
Set:   29.  GPS Wk: 2246  Hr:  96  Sec:  345600  2023-01-25 23:59:46 to 2023-01-26 05:59:46 UTC
Set:   30.  GPS Wk: 2246  Hr: 102  Sec:  367200  2023-01-26 05:59:46 to 2023-01-26 11:59:46 UTC
Set:   31.  GPS Wk: 2246  Hr: 108  Sec:  388800  2023-01-26 11:59:46 to 2023-01-26 17:59:46 UTC
Set:   32.  GPS Wk: 2246  Hr: 114  Sec:  410400  2023-01-26 17:59:46 to 2023-01-26 23:59:46 UTC
Set:   33.  GPS Wk: 2246  Hr: 120  Sec:  432000  2023-01-26 23:59:46 to 2023-01-27 05:59:46 UTC
Set:   34.  GPS Wk: 2246  Hr: 126  Sec:  453600  2023-01-27 05:59:46 to 2023-01-27 11:59:46 UTC
Set:   35.  GPS Wk: 2246  Hr: 132  Sec:  475200  2023-01-27 11:59:46 to 2023-01-27 17:59:46 UTC
Set:   36.  GPS Wk: 2246  Hr: 138  Sec:  496800  2023-01-27 17:59:46 to 2023-01-27 23:59:46 UTC
Set:   37.  GPS Wk: 2246  Hr: 144  Sec:  518400  2023-01-27 23:59:46 to 2023-01-28 05:59:46 UTC
Set:   38.  GPS Wk: 2246  Hr: 150  Sec:  540000  2023-01-28 05:59:46 to 2023-01-28 11:59:46 UTC
Set:   39.  GPS Wk: 2246  Hr: 156  Sec:  561600  2023-01-28 11:59:46 to 2023-01-28 17:59:46 UTC
Set:   40.  GPS Wk: 2246  Hr: 162  Sec:  583200  2023-01-28 17:59:46 to 2023-01-28 23:59:46 UTC
Set:   41.  GPS Wk: 2247  Hr:   0  Sec:       0  2023-01-28 23:59:46 to 2023-01-29 05:59:46 UTC
Set:   42.  GPS Wk: 2247  Hr:   6  Sec:   21600  2023-01-29 05:59:46 to 2023-01-29 11:59:46 UTC
Set:   43.  GPS Wk: 2247  Hr:  12  Sec:   43200  2023-01-29 11:59:46 to 2023-01-29 17:59:46 UTC
Set:   44.  GPS Wk: 2247  Hr:  18  Sec:   64800  2023-01-29 17:59:46 to 2023-01-29 23:59:46 UTC
Set:   45.  GPS Wk: 2247  Hr:  24  Sec:   86400  2023-01-29 23:59:46 to 2023-01-30 05:59:46 UTC
Set:   46.  GPS Wk: 2247  Hr:  30  Sec:  108000  2023-01-30 05:59:46 to 2023-01-30 11:59:46 UTC
Set:   47.  GPS Wk: 2247  Hr:  36  Sec:  129600  2023-01-30 11:59:46 to 2023-01-30 17:59:46 UTC
Set:   48.  GPS Wk: 2247  Hr:  42  Sec:  151200  2023-01-30 17:59:46 to 2023-01-30 23:59:46 UTC
Set:   49.  GPS Wk: 2247  Hr:  48  Sec:  172800  2023-01-30 23:59:46 to 2023-01-31 05:59:46 UTC
Set:   50.  GPS Wk: 2247  Hr:  54  Sec:  194400  2023-01-31 05:59:46 to 2023-01-31 11:59:46 UTC
Set:   51.  GPS Wk: 2247  Hr:  60  Sec:  216000  2023-01-31 11:59:46 to 2023-01-31 17:59:46 UTC
Set:   52.  GPS Wk: 2247  Hr:  66  Sec:  237600  2023-01-31 17:59:46 to 2023-01-31 23:59:46 UTC
Set:   53.  GPS Wk: 2247  Hr:  72  Sec:  259200  2023-01-31 23:59:46 to 2023-02-01 05:59:46 UTC
Set:   54.  GPS Wk: 2247  Hr:  78  Sec:  280800  2023-02-01 05:59:46 to 2023-02-01 11:59:46 UTC
Set:   55.  GPS Wk: 2247  Hr:  84  Sec:  302400  2023-02-01 11:59:46 to 2023-02-01 17:59:46 UTC
Set:   56.  GPS Wk: 2247  Hr:  90  Sec:  324000  2023-02-01 17:59:46 to 2023-02-01 23:59:46 UTC
Set:   57.  GPS Wk: 2247  Hr:  96  Sec:  345600  2023-02-01 23:59:46 to 2023-02-02 05:59:46 UTC
Set:   58.  GPS Wk: 2247  Hr: 102  Sec:  367200  2023-02-02 05:59:46 to 2023-02-02 11:59:46 UTC
Set:   59.  GPS Wk: 2247  Hr: 108  Sec:  388800  2023-02-02 11:59:46 to 2023-02-02 17:59:46 UTC
Set:   60.  GPS Wk: 2247  Hr: 114  Sec:  410400  2023-02-02 17:59:46 to 2023-02-02 23:59:46 UTC
Set:   61.  GPS Wk: 2247  Hr: 120  Sec:  432000  2023-02-02 23:59:46 to 2023-02-03 05:59:46 UTC
Set:   62.  GPS Wk: 2247  Hr: 126  Sec:  453600  2023-02-03 05:59:46 to 2023-02-03 11:59:46 UTC
Set:   63.  GPS Wk: 2247  Hr: 132  Sec:  475200  2023-02-03 11:59:46 to 2023-02-03 17:59:46 UTC
Set:   64.  GPS Wk: 2247  Hr: 138  Sec:  496800  2023-02-03 17:59:46 to 2023-02-03 23:59:46 UTC
Set:   65.  GPS Wk: 2247  Hr: 144  Sec:  518400  2023-02-03 23:59:46 to 2023-02-04 05:59:46 UTC
Set:   66.  GPS Wk: 2247  Hr: 150  Sec:  540000  2023-02-04 05:59:46 to 2023-02-04 11:59:46 UTC
Set:   67.  GPS Wk: 2247  Hr: 156  Sec:  561600  2023-02-04 11:59:46 to 2023-02-04 17:59:46 UTC
Set:   68.  GPS Wk: 2247  Hr: 162  Sec:  583200  2023-02-04 17:59:46 to 2023-02-04 23:59:46 UTC
Set:   69.  GPS Wk: 2248  Hr:   0  Sec:       0  2023-02-04 23:59:46 to 2023-02-05 05:59:46 UTC
Set:   70.  GPS Wk: 2248  Hr:   6  Sec:   21600  2023-02-05 05:59:46 to 2023-02-05 11:59:46 UTC
Set:   71.  GPS Wk: 2248  Hr:  12  Sec:   43200  2023-02-05 11:59:46 to 2023-02-05 17:59:46 UTC
Set:   72.  GPS Wk: 2248  Hr:  18  Sec:   64800  2023-02-05 17:59:46 to 2023-02-05 23:59:46 UTC
Set:   73.  GPS Wk: 2248  Hr:  24  Sec:   86400  2023-02-05 23:59:46 to 2023-02-06 05:59:46 UTC
Set:   74.  GPS Wk: 2248  Hr:  30  Sec:  108000  2023-02-06 05:59:46 to 2023-02-06 11:59:46 UTC
Set:   75.  GPS Wk: 2248  Hr:  36  Sec:  129600  2023-02-06 11:59:46 to 2023-02-06 17:59:46 UTC
Set:   76.  GPS Wk: 2248  Hr:  42  Sec:  151200  2023-02-06 17:59:46 to 2023-02-06 23:59:46 UTC
Set:   77.  GPS Wk: 2248  Hr:  48  Sec:  172800  2023-02-06 23:59:46 to 2023-02-07 05:59:46 UTC
Set:   78.  GPS Wk: 2248  Hr:  54  Sec:  194400  2023-02-07 05:59:46 to 2023-02-07 11:59:46 UTC
Set:   79.  GPS Wk: 2248  Hr:  60  Sec:  216000  2023-02-07 11:59:46 to 2023-02-07 17:59:46 UTC
Set:   80.  GPS Wk: 2248  Hr:  66  Sec:  237600  2023-02-07 17:59:46 to 2023-02-07 23:59:46 UTC
Set:   81.  GPS Wk: 2248  Hr:  72  Sec:  259200  2023-02-07 23:59:46 to 2023-02-08 05:59:46 UTC
Set:   82.  GPS Wk: 2248  Hr:  78  Sec:  280800  2023-02-08 05:59:46 to 2023-02-08 11:59:46 UTC
Set:   83.  GPS Wk: 2248  Hr:  84  Sec:  302400  2023-02-08 11:59:46 to 2023-02-08 17:59:46 UTC
Set:   84.  GPS Wk: 2248  Hr:  90  Sec:  324000  2023-02-08 17:59:46 to 2023-02-08 23:59:46 UTC
Set:   85.  GPS Wk: 2248  Hr:  96  Sec:  345600  2023-02-08 23:59:46 to 2023-02-09 05:59:46 UTC
Set:   86.  GPS Wk: 2248  Hr: 102  Sec:  367200  2023-02-09 05:59:46 to 2023-02-09 11:59:46 UTC
Set:   87.  GPS Wk: 2248  Hr: 108  Sec:  388800  2023-02-09 11:59:46 to 2023-02-09 17:59:46 UTC
Set:   88.  GPS Wk: 2248  Hr: 114  Sec:  410400  2023-02-09 17:59:46 to 2023-02-09 23:59:46 UTC
Set:   89.  GPS Wk: 2248  Hr: 120  Sec:  432000  2023-02-09 23:59:46 to 2023-02-10 05:59:46 UTC
Set:   90.  GPS Wk: 2248  Hr: 126  Sec:  453600  2023-02-10 05:59:46 to 2023-02-10 11:59:46 UTC
Set:   91.  GPS Wk: 2248  Hr: 132  Sec:  475200  2023-02-10 11:59:46 to 2023-02-10 17:59:46 UTC
Set:   92.  GPS Wk: 2248  Hr: 138  Sec:  496800  2023-02-10 17:59:46 to 2023-02-10 23:59:46 UTC
Set:   93.  GPS Wk: 2248  Hr: 144  Sec:  518400  2023-02-10 23:59:46 to 2023-02-11 05:59:46 UTC
Set:   94.  GPS Wk: 2248  Hr: 150  Sec:  540000  2023-02-11 05:59:46 to 2023-02-11 11:59:46 UTC
Set:   95.  GPS Wk: 2248  Hr: 156  Sec:  561600  2023-02-11 11:59:46 to 2023-02-11 17:59:46 UTC
Set:   96.  GPS Wk: 2248  Hr: 162  Sec:  583200  2023-02-11 17:59:46 to 2023-02-11 23:59:46 UTC
Set:   97.  GPS Wk: 2249  Hr:   0  Sec:       0  2023-02-11 23:59:46 to 2023-02-12 05:59:46 UTC
Set:   98.  GPS Wk: 2249  Hr:   6  Sec:   21600  2023-02-12 05:59:46 to 2023-02-12 11:59:46 UTC
Set:   99.  GPS Wk: 2249  Hr:  12  Sec:   43200  2023-02-12 11:59:46 to 2023-02-12 17:59:46 UTC
Set:  100.  GPS Wk: 2249  Hr:  18  Sec:   64800  2023-02-12 17:59:46 to 2023-02-12 23:59:46 UTC
Set:  101.  GPS Wk: 2249  Hr:  24  Sec:   86400  2023-02-12 23:59:46 to 2023-02-13 05:59:46 UTC
Set:  102.  GPS Wk: 2249  Hr:  30  Sec:  108000  2023-02-13 05:59:46 to 2023-02-13 11:59:46 UTC
Set:  103.  GPS Wk: 2249  Hr:  36  Sec:  129600  2023-02-13 11:59:46 to 2023-02-13 17:59:46 UTC
Set:  104.  GPS Wk: 2249  Hr:  42  Sec:  151200  2023-02-13 17:59:46 to 2023-02-13 23:59:46 UTC
Set:  105.  GPS Wk: 2249  Hr:  48  Sec:  172800  2023-02-13 23:59:46 to 2023-02-14 05:59:46 UTC
Set:  106.  GPS Wk: 2249  Hr:  54  Sec:  194400  2023-02-14 05:59:46 to 2023-02-14 11:59:46 UTC
Set:  107.  GPS Wk: 2249  Hr:  60  Sec:  216000  2023-02-14 11:59:46 to 2023-02-14 17:59:46 UTC
Set:  108.  GPS Wk: 2249  Hr:  66  Sec:  237600  2023-02-14 17:59:46 to 2023-02-14 23:59:46 UTC
Set:  109.  GPS Wk: 2249  Hr:  72  Sec:  259200  2023-02-14 23:59:46 to 2023-02-15 05:59:46 UTC
Set:  110.  GPS Wk: 2249  Hr:  78  Sec:  280800  2023-02-15 05:59:46 to 2023-02-15 11:59:46 UTC
Set:  111.  GPS Wk: 2249  Hr:  84  Sec:  302400  2023-02-15 11:59:46 to 2023-02-15 17:59:46 UTC
Set:  112.  GPS Wk: 2249  Hr:  90  Sec:  324000  2023-02-15 17:59:46 to 2023-02-15 23:59:46 UTC
Set:  113.  GPS Wk: 2249  Hr:  96  Sec:  345600  2023-02-15 23:59:46 to 2023-02-16 05:59:46 UTC
Set:  114.  GPS Wk: 2249  Hr: 102  Sec:  367200  2023-02-16 05:59:46 to 2023-02-16 11:59:46 UTC
Set:  115.  GPS Wk: 2249  Hr: 108  Sec:  388800  2023-02-16 11:59:46 to 2023-02-16 17:59:46 UTC
Set:  116.  GPS Wk: 2249  Hr: 114  Sec:  410400  2023-02-16 17:59:46 to 2023-02-16 23:59:46 UTC
Set:  117.  GPS Wk: 2249  Hr: 120  Sec:  432000  2023-02-16 23:59:46 to 2023-02-17 05:59:46 UTC
Set:  118.  GPS Wk: 2249  Hr: 126  Sec:  453600  2023-02-17 05:59:46 to 2023-02-17 11:59:46 UTC
Set:  119.  GPS Wk: 2249  Hr: 132  Sec:  475200  2023-02-17 11:59:46 to 2023-02-17 17:59:46 UTC
Set:  120.  GPS Wk: 2249  Hr: 138  Sec:  496800  2023-02-17 17:59:46 to 2023-02-17 23:59:46 UTC
 120 EPO sets.  Valid from 2023-01-18 23:59:46 to 2023-02-17 23:59:46 UTC

Twelve sets:

root@ B-NTPsec: /usr/local/bin # update-epo
EPO data saved to /var/tmp/EPO.DAT
Opening EPO Type II file with 120 sets
GPS Version:  ['PMTK705', 'AXN_2.31_3339_13101700', '5632', 'PA6H', '1.0']
Setting known values: 38.xxx,-122.xxx,41  2023,01,19,04,07,41
Time set
Location set
Clearing existing EPO data
Setting binary mode, speed: 115200
Sending 12 EPO sets of 120
Sending set    1.  Valid from 2023-01-18 23:59:46 UTC
Sending set    2.  Valid from 2023-01-19 05:59:46 UTC
Sending set    3.  Valid from 2023-01-19 11:59:46 UTC
Sending set    4.  Valid from 2023-01-19 17:59:46 UTC
Sending set    5.  Valid from 2023-01-19 23:59:46 UTC
Sending set    6.  Valid from 2023-01-20 05:59:46 UTC
Sending set    7.  Valid from 2023-01-20 11:59:46 UTC
Sending set    8.  Valid from 2023-01-20 17:59:46 UTC
Sending set    9.  Valid from 2023-01-20 23:59:46 UTC
Sending set   10.  Valid from 2023-01-21 05:59:46 UTC
Sending set   11.  Valid from 2023-01-21 11:59:46 UTC
Sending set   12.  Valid from 2023-01-21 17:59:46 UTC
  12 sets sent.  Valid from 2023-01-18 23:59:46 to 2023-01-21 23:59:46 UTC
ERROR: EPO in NVRAM doesnt match file
  In NVRAM: 2023-01-18 23:59:46 to 2007-08-03 12:59:46 UTC

Port speed 57600:

root@ B-NTPsec: /usr/local/bin # update-epo
EPO data saved to /var/tmp/EPO.DAT
Opening EPO Type II file with 120 sets
Unable to save enabled messages
Setting known values: 38.xxx,-122.xxx,41  2023,01,19,04,10,07
ERROR: Unable to set time. None

Weird issue! And thanks for looking into it.

(Note, I modified my shell script to also use the ${SPEED} variable in the stty call, so no mismatch)

@gtjoseph
Copy link
Owner

OK, I think I may have a math problem that only shows up in certain circumstances. Give me a few days to iron it out. In the mean time, send 24 sets instead of 26. That seems to work reliably for me.

@gtjoseph
Copy link
Owner

Give version v1.2.0 a shot. I've updated the code to be more reliable but with my latest experimentation, the NVRAM on the device can only hold 23 sets so make sure you use -m 23.
If it still doesn't work, save the EPO.DAT file and attach it to this issue so I can test with it.

@bclaymiles
Copy link
Author

Will try it out now. Thank you kindly for your efforts!

@bclaymiles
Copy link
Author

No errors, worked fine - after pip installing pre_commit, which apparently wasn't a dependency previously.

@gtjoseph
Copy link
Owner

pre_commit? Hmmm. I wonder how that get in there.
I just pushed up a new release that removes that import. Sorry about that.

@bclaymiles
Copy link
Author

I'll check the new release, but for some reason I'm getting an assortment of odd errors now. I'll report back if the new update doesn't mitigate that.

@bclaymiles
Copy link
Author

(posting this but see next post as I dug deeper)

Nope, no change. running my script, unchanged from above except using 23 sets as recommended - and with debug turned on - the output now is:

EPO data saved to /var/tmp/EPO.DAT
Opening EPO Type II file with 120 sets
>> $PMTK414*33
<< 
>> $PMTK414*33
<< 
>> $PMTK414*33
<< 
Unable to save enabled messages
>> $PMTK605*31
<< 
>> $PMTK605*31
<< 
>> $PMTK605*31
<< 
Setting known values: 38.332055,-122.688810,41  2023,01,23,04,31,25
>> $PMTK740,2023,01,23,04,31,25*33
<< 
>> $PMTK740,2023,01,23,04,31,25*33
<< 
>> $PMTK740,2023,01,23,04,31,25*33
<< 
ERROR: Unable to set time. None

@bclaymiles
Copy link
Author

After the results above, I ran gpsinit -f /etc/gpsinit_time.conf. I forgot to add the speed, and got the following output:

root@ B-NTPsec: /usr/local/src/mt3339-utils-1.2.1 # gpsinit -f /etc/gpsinit_time.conf  /dev/gpsd0
Setting NMEA at 9600 baud.
   Unit is currently in NMEA mode at 9600 baud.
GPS and port are now synchronized at 9600
Failed to get ACK.
Processing commands...
>> PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0
Failed to get ACK.
1
Done

So I then ran it properly with correct speed, and of course it had to renogiate with the chip:

root@ B-NTPsec: /usr/local/src/mt3339-utils-1.2.1 # gpsinit -f /etc/gpsinit_time.conf  -s 115200 /dev/gpsd0
Setting NMEA at 115200 baud.
   No response.  Seeing if it's in binary mode.
   Apparently not. Failed.
GPS isn't at the desired 115200 baud rate.  Trying the current port rate of 57600 baud.
Setting NMEA at 57600 baud.
   No response.  Seeing if it's in binary mode.
   Apparently not. Failed.
GPS isn't at the current port rate either.
Setting NMEA at 4800 baud.
   No response.  Seeing if it's in binary mode.
   Apparently not. Failed.
Setting NMEA at 9600 baud.
   Unit is currently in NMEA mode at 9600 baud.
Found unit at 9600 baud.  Attempting to set it to 115200 baud
GPS and port are now synchronized at 115200
Processing commands...
>> PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0
Failed to get ACK.
1
Done

I've gotten those failed ack's so often, even when things appeared to be working fine, i gradually just ignored them. I think that is still generally the case - they're spurious, but maybe I'm wrong.

Here's the output from the update-epo script now - but first to be sure I didn't bork something, here's the script in its current state, which should be fine:

#!/bin/bash
LAT="38.332055"
LON="-122.688810"
ALT="41"
SPEED="115200"
DEV="/dev/gpsd0"
FILE="/var/tmp/EPO.DAT"
MAXSETS="23"
nice /usr/local/bin/eporetrieve
/bin/systemctl stop gpsd
stty -F ${DEV} raw ${SPEED} cs8 clocal -cstopb
#/usr/local/bin/gpsinit -s 115200 -f /etc/gpsinit_time.conf /dev/gpsd0
nice /usr/local/bin/gpssend clear_epo ${DEV}
nice /usr/local/bin/epoloader -d -s ${SPEED} --no-init -k -c --max-sets=${MAXSETS} -l=${LAT},${LON},${ALT} -t- ${FILE} ${DEV}
/bin/systemctl start gpsd

And the output (and I know I left the coordinates in, even though I was eliding them previously. Paranoia can become annoying!)

EPO data saved to /var/tmp/EPO.DAT
Opening EPO Type II file with 120 sets
>> $PMTK414*33
<< $GPGGA,044417.000,3819.9210,N,12241.3301,W,2,09,1.06,21.3,M,-24.7,M,0000,0000*61
>> $PMTK414*33
<< $PMTK514,0,1,0,1,1,5,0,0,0,0,0,0,0,0,0,0,0,1,0*2B
>> $PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28
<< $PMTK001,314,3*36
>> $PMTK605*31
<< $PMTK705,AXN_2.31_3339_13101700,5632,PA6H,1.0*6B
GPS Version:  ['PMTK705', 'AXN_2.31_3339_13101700', '5632', 'PA6H', '1.0']
Setting known values: 38.332055,-122.688810,41  2023,01,23,04,44,18
>> $PMTK740,2023,01,23,04,44,18*3f
<< $PMTK001,740,3*33
Time set
>> $PMTK741,38.332055,-122.688810,41,2023,01,23,04,44,18*0d
<< $PMTK001,741,3*32
Location set
Clearing existing EPO data
>> $PMTK127*36
<< $CLR,EPO,000a0000*56
Setting binary mode, speed: 115200
>> $PMTK253,1,115200*00
Sending 23 EPO sets of 120
Sending set    1.  Valid from 2023-01-22 23:59:46 UTC to 2023-01-23 05:59:46 UTC
Sending set    2.  Valid from 2023-01-23 05:59:46 UTC to 2023-01-23 11:59:46 UTC
Sending set    3.  Valid from 2023-01-23 11:59:46 UTC to 2023-01-23 17:59:46 UTC
Sending set    4.  Valid from 2023-01-23 17:59:46 UTC to 2023-01-23 23:59:46 UTC
Sending set    5.  Valid from 2023-01-23 23:59:46 UTC to 2023-01-24 05:59:46 UTC
Sending set    6.  Valid from 2023-01-24 05:59:46 UTC to 2023-01-24 11:59:46 UTC
Sending set    7.  Valid from 2023-01-24 11:59:46 UTC to 2023-01-24 17:59:46 UTC
Sending set    8.  Valid from 2023-01-24 17:59:46 UTC to 2023-01-24 23:59:46 UTC
Sending set    9.  Valid from 2023-01-24 23:59:46 UTC to 2023-01-25 05:59:46 UTC
Sending set   10.  Valid from 2023-01-25 05:59:46 UTC to 2023-01-25 11:59:46 UTC
Sending set   11.  Valid from 2023-01-25 11:59:46 UTC to 2023-01-25 17:59:46 UTC
Sending set   12.  Valid from 2023-01-25 17:59:46 UTC to 2023-01-25 23:59:46 UTC
Sending set   13.  Valid from 2023-01-25 23:59:46 UTC to 2023-01-26 05:59:46 UTC
Sending set   14.  Valid from 2023-01-26 05:59:46 UTC to 2023-01-26 11:59:46 UTC
Sending set   15.  Valid from 2023-01-26 11:59:46 UTC to 2023-01-26 17:59:46 UTC
Sending set   16.  Valid from 2023-01-26 17:59:46 UTC to 2023-01-26 23:59:46 UTC
Sending set   17.  Valid from 2023-01-26 23:59:46 UTC to 2023-01-27 05:59:46 UTC
Sending set   18.  Valid from 2023-01-27 05:59:46 UTC to 2023-01-27 11:59:46 UTC
Sending set   19.  Valid from 2023-01-27 11:59:46 UTC to 2023-01-27 17:59:46 UTC
Sending set   20.  Valid from 2023-01-27 17:59:46 UTC to 2023-01-27 23:59:46 UTC
Sending set   21.  Valid from 2023-01-27 23:59:46 UTC to 2023-01-28 05:59:46 UTC
Sending set   22.  Valid from 2023-01-28 05:59:46 UTC to 2023-01-28 11:59:46 UTC
Sending set   23.  Valid from 2023-01-28 11:59:46 UTC to 2023-01-28 17:59:46 UTC
================================================================================
>> $PMTK000*32
<< 
>> $PMTK000*32
>> $PMTK000*32
<< $PMTK001,0,3*30
>> $PMTK607*33
<< $PMTK707,56,2246,89680,2903,86512,0,0,0,0*10
>> $PMTK314,0,1,0,1,1,5,0,0,0,0,0,0,0,0,0,0,0,1,0*2d
<< $PMTK001,314,3*36
 23 sets sent.     Valid from 2023-01-22 23:59:46 UTC to 2023-01-28 17:59:46 UTC
    sets in NVRAM: Valid from 2023-01-22 23:59:46 UTC to 2035-08-27 05:59:46 UTC
ERROR: EPO in NVRAM doesnt match file

The telltale wtf should be obvious - sets to 2035. So, I tried sending just two sets. That got a successful 'verified'. Sent 22 sets; 'verified'. 23, failed. various iterations up to the full 120 sets, all failed.

I ran a gpsinit -f /usr/local/bin/gpsinit_reset.conf -s 115200 /dev/gpsd0, (which still sends 26 sets by default, btw) - but that failed to fix it either, even after setting the default within epoloader to 23.

I ran into this once before, with the way out-of-bounds sets in nvram. I have a feeling the only fix is for me to shut down the Pi, disassemble the case, and take out the backup battery so that it loses everything. Sigh. It's a beautiful clear case made of stacks of carefully cut acrylic, which is a massive pain to pull apart.

At this point, I dont think it's anything at all to do with your code, it's just some sort of corruption the chip is prone to.

Whee!

@bclaymiles
Copy link
Author

Dang. Battery pulled, waited a bit, battery restored, boot and get system sorted out with a reasonable time, gpsinit_reset, run update-epo script with 23 sets - same failure, same bad ending date -

 23 sets sent.     Valid from 2023-01-22 23:59:46 UTC to 2023-01-28 17:59:46 UTC
    sets in NVRAM: Valid from 2023-01-22 23:59:46 UTC to 2035-08-27 05:59:46 UTC
ERROR: EPO in NVRAM doesnt match file

I'm lost at this point.

Very very minor typo run across in eporetrieve, next to last line:
echo "EPO.DAT checkdum failed"

Although I kind of like checkdum.

@gtjoseph
Copy link
Owner

sigh. I'm just not sure where to go next. The MT3339 was not originally designed to use EPO-II files and I think the firmware update that allowed it to use them wasn't quite fully tested. You can see evidence of this in the PMTK707 response message...
<< $PMTK707,56,2246,89680,2903,86512,0,0,0,0*10
The 56 is the number of sets it has in NVRAM which would be correct if it were actually storing an EPO-I file so it's quite possible there are other bugs in the implementation.

Anyway... I just downloaded a new EPO.DAT and it has the same start and end dates as the one you just tested. Guess what? It fails for me as well. However if I do 22 sets, it works fine. The one from 2 days ago that starts at 2023-01-20-23:59:49 works fine at 23.

I'm going to have to collect a few days of files to see if I can find a pattern. I'll also see if there's some other source of EPO data I can use.

@gtjoseph gtjoseph reopened this Jan 23, 2023
@bclaymiles
Copy link
Author

This issue is almost comical! Yeah, wouldn't surprise me if it's a faulty firmware update that leaves potentially corrupt data behind sometimes. It's interesting that your downloaded EPO doesn't work either - it couldn't be a bad epo that MTK has generated??

Anyway - really appreciate your efforts. For now I've swapped in place my backup Pi which has a ublox hat. It keeps decent time, just not quite as good as the Adafruit board.

While further poking around I noticed that Adafruit swapped the chip on their Ultimate GPS hat to one using the MT3333 - aparrently the MT3339 is discontinued.

@bclaymiles
Copy link
Author

Just ran update, 22 sets, worked fine. Really makes me think maybe it's a problem with MTK's files...

@gtjoseph
Copy link
Owner

I'm surprised the ublox isn't better. I now use the F9Z which is expensive but even the Neo- M9 was better than the MTK device. The MT3333 (which works no better than the 3339 BTW) I thought was also discontinued. Maybe there's just more stock left

Anyway, I've downloaded a bunch of sets, some from MT and some from Garmin and they have exactly the same data in them so I think Garmin gets them from MT. The interesting thing is that for the same file, I can get 22, 23, 24, 25 or 26 good sets loaded depending on where I start in the file. I'm wondering if it has to do with where the GPS week changes over in the sequence. When I've got a few more files, I'm going to let a test run with all the combinations of starting set and set count and see what happens.

@bclaymiles
Copy link
Author

In my case it's a ublox Neo M8T, on a HAT built by...some tiny drone company on ebay that I bought a couple from a few years ago, and which no longer sells anything. It's not bad per se -
https://ntpsec.anastrophe.com/a-1hr/index.html

But the time jitter on the Adafruit is in nanoseconds rather than microseconds. It's also entirely possible it's just something with that particular Raspberry Pi's host hardware.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants