Ublox GPS checksum in Oshonsoft BASIC

Thread Starter

camerart

Joined Feb 25, 2013
3,724
Hi,
I'm trying to set-up and READ SPI NMEA sentences from a NEO-M8 GPS, in Oshonsoft BASIC.

In the [u-blox M8 Receiver description Including protocol specification PDF] https://content.u-blox.com/sites/de...ox8-M8_ReceiverDescrProtSpec_UBX-13003221.pdf
on Page 171, 32.4 There is a calculation section explaining how to calculate the checksum, but I can't quite understand it, can anyone help please?
Cheers, Camerart

Mod: Page Clip.E

ScreenHunter 23.gif
 
Last edited by a moderator:

Thread Starter

camerart

Joined Feb 25, 2013
3,724
I thought the checksum was a simple XOR?

https://nmeachecksum.eqth.net/
Hi U,
Thanks for the calculator.
I tried a couple of known examples, and the checksums were different. It's possible that I didn't use it correctly.

What I'm trying to do is send the relevent BYTE STRINGS from the [ u-blox M8 Receiver description Including protocol specification PDF] and receive NMEA sentences.
I can see the example calculation shown, but not understand it.
C
 

nsaspook

Joined Aug 27, 2009
13,086
https://www.ietf.org/rfc/rfc1145.txt
APPENDIX I: The 8-bit Fletcher Checksum Algorithm

The 8-bit Fletcher Checksum Algorithm is calculated over a sequence
of data octets (call them D[1] through D[N]) by maintaining 2
unsigned 1's-complement 8-bit accumulators A and B whose contents are
initially zero, and performing the following loop where i ranges from
1 to N:

A := A + D
B := B + A

It can be shown that at the end of the loop A will contain the 8-bit
1's complement sum of all octets in the datagram, and that B will



Zweig & Partridge [Page 3]

RFC 1145 TCP Alternate Checksum Options February 1990


contain (N)D[1] + (N-1)D[2] + ... + D[N].

The octets covered by this algorithm should be the same as those over
which the standard TCP checksum calculation is performed, with the
pseudoheader being D[1] through D[12] and the TCP header beginning at
D[13]. Note that, for purposes of the checksum computation, the
checksum field itself must be equal to zero.

At the end of the loop, the A goes in the first byte of the TCP
checksum and B goes in the second byte.

Note that, unlike the OSI version of the Fletcher checksum, this
checksum does not adjust the check bytes so that the receiver
checksum is 0.

There are a number of much faster algorithms for calculating the two
octets of the 8-bit Fletcher checksum. For more information see
[Sklower89], [Nakassis88] and [Fletcher82]. Naturally, any
computation which computes the same number as would be calculated by
the loop above may be used to calculate the checksum. One advantage
of the Fletcher algorithms over the standard TCP checksum algorithm
is the ability to detect the transposition of octets/words of any
size within a datagram.
 

upand_at_them

Joined May 15, 2010
940
Hi U,
Thanks for the calculator.
I tried a couple of known examples, and the checksums were different. It's possible that I didn't use it correctly.

What I'm trying to do is send the relevent BYTE STRINGS from the [ u-blox M8 Receiver description Including protocol specification PDF] and receive NMEA sentences.
I can see the example calculation shown, but not understand it.
C
I have an old GPS log file and I ran a couple of the sentences through that calculator and got the correct checksum for each. Post an example of your data.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,724
I mean the actual data coming out of the uBlox unit.
Hi U,
I think we have a misunderstanding, I am trying to send messages as in the last post, in order to receive $NMEA sentences, that arrive from the GPS complete with their checksum.

If it possible to convert:
===================================
CK_A = 0, CK_B = 0
For(I=0;I<N;I++)
{
CK_A = CK_A + Buffer
CK_B = CK_B + CK_A
}
=================================

into BASIC, job done.
Thanks for trying,
C
 

Thread Starter

camerart

Joined Feb 25, 2013
3,724
Sorry, my mistake.
Hi U,
That's ok, at least you tried, thanks.
I also posted on a computer forum, and they came back with this:
==========================================
N = 10
Buffer = 1
CK_A = 0
CK_B = 0
For i = 0 to N step 1
CK_A = CK_A + Buffer
CK_B = CK_B + CK_A
Next i
==============================================
He had to add 'N' and 'BUFFER' to get it to work.
I assume that 'N' is the number of BYTEs in the string, I'm not sure about buffer.
I'll try a few things with example, and see what happens.
C
 

jjw

Joined Dec 24, 2013
823
Hi U,
That's ok, at least you tried, thanks.
I also posted on a computer forum, and they came back with this:
==========================================
N = 10
Buffer = 1
CK_A = 0
CK_B = 0
For i = 0 to N step 1
CK_A = CK_A + Buffer
CK_B = CK_B + CK_A
Next i
==============================================
He had to add 'N' and 'BUFFER' to get it to work.
I assume that 'N' is the number of BYTEs in the string, I'm not sure about buffer.
I'll try a few things with example, and see what happens.
C
I guess it should be Buffer(i) inside the loop, where Buffer is an Array for the message ( payload)
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,724
Hi,
Before adding the CODE in #15, I am trying to get a response from the NEO-8 using long hand.
I have joined bits from other programs that seem correct, but I don't think it quite right. Can someone check if I'm on the right lines please?

I'm trying to SEND '0xB5,0x62,0x0A,0x04,0x00,0x00,0x0E,0x34' (which is the version) and should illicit a response from the NEO-8
Here is my CODE:
https://drive.google.com/file/d/15QVOYEJZkJwdEGD8faOcVvJnYrZ6QzbE/view?usp=sharing
C.
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,724
Why don't you post the code?
Google drive needs your permission to see the code.
Hi J and s,
I tried posting the CODE as an insert and as an attachment, but I wasn't allowed. I've had this before, and thought that as long as it wasn't a BAS file and posted as a TXT file, it would work.
I'll see if I can give permission.
EDIT: Try to open the link, I think it should open
Cheers, C.
 
Last edited:
Top