-
• #2
I have tried to make the PCAS-commands a bit more usable in a library, but some seem to do nothing at all (e.g. setting Standby mode) while other work fine (update interval). Is there a way to dump the current config to check?
Does your command miss the checksum or did you omit that on purpose?
https://github.com/halemmerich/BangleApps/blob/pcas/modules/pcas.js
-
• #3
There is some helpful code at http://www.espruino.com/Bangle.js2+Technical#gps that might help? It at least calculates the CRC
-
• #4
Thank for the reply. The post misses the checksum. The real code is:
function checksum(str) { var cs = 0; for (const c of str) { cs = cs ^ c.charCodeAt(0); //XOR } return cs.toString(16).toUpperCase().padStart(2, '0'); } function configureSBAS() { const thisTime = new Date(); let timeString = thisTime.toISOString(); // SBAS satellite (SBAS satellite No. 1-19, corresponding to PRN 120-138 var cmd = "PCAS15,4,FFFF"; //turn on satellites 1-16 of SBAS //var cmd = "PCAS15,4,7FFFF"; //turn on satellites 1-19 of SBAS cmd = "$" + cmd + "*" + checksum(cmd); Serial1.println(cmd); writeLogFile(timeString + ": " + cmd + "\n"); SBASon = true; }
-
• #5
You are checksumming the command without the leading
$
, I think that needs to be included. -
• #6
I thing line 19 of the presented code add the leading "$"
-
• #7
It does, but that happens after the checksum is calculated. The
cmd
going intochecksum()
does not yet contain it. -
• #8
I'm not sure if "$" should be accounted in the checksum.
As shown here, NMEA checksum calculation does not include "$" and "*"Lets assume the following NMEA sentence:
$GPGLL,5300.97914,N,00259.98174,E,125926,A*28
In this sentence the checksum is the character representation of the
hexadecimal value 28. The string that the checksum is calculated over
isGPGLL,5300.97914,N,00259.98174,E,125926,A
To calculate the checksum you parse all characters between $ and *
from the NMEA sentence into a new string. -
• #9
I have tried it with
PCAS02
, the command to change the update rate and without the$
included in the checksum it changes nothing while including it works.print(require("pcas").checksum("$GPGLL,5300.97914,N,00259.98174,E,125926,A"));
creates a checksum of28
which matches your example. Doing the same without$
calculates6F
as checksum.require("pcas").checksum
is as follows:function checksum(cmd) { var cs = 0; for (var i = 1; i < cmd.length; i++) cs = cs ^ cmd.charCodeAt(i); return cmd + "*" + cs.toString(16).toUpperCase().padStart(2, '0'); }
-
• #11
Oh wow, the confusion was on my end 😑.
My function ignores the first character and so it needs the$
given to it to directly ignore it...
Playing with @BillM 's code. Despite forcing AT6558(R?) into the SBAS mode by sending
to the chip, the error is still over 7 meters.
Is there a way to get the error below 2 meters as stated in most SBAS articles?
UPD:
After taking weighted by time between records average of recorded coordinates at a static point and comparing those average coordinates to the true coordinates, the error seems to be closer to 20 meters.
UPD2:
The command checksum is not included in the post. When the command is sent to the GPS chip the checksum is added.