Shop OBEX P1 Docs P2 Docs Learn Events
Calculating NMEA checksum — Parallax Forums

Calculating NMEA checksum

Bstamp_gpsBstamp_gps Posts: 9
edited 2006-06-16 23:06 in BASIC Stamp
Has anyone calculated the NMEA checksum with Basic Stamp?

In fact,·I receive the NMEA data·(which is done), do some·modifications·(which is done), recalculate the checksum·(which is not yet done)·and retransmit on another port·(done).

I have searched for the procedure to do this calculation on the internet - however, with no success.

Would much appreciate any assistance.· Thanks for any help ...

turn.gif·

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-06-16 19:12
    Isn't it the XOR of everything in front of the asterisk?

    Post edit --
    http://www.codepedia.com/1/Calculating+and+Validating+NMEA+Checksums

    Post Edited (PJ Allen) : 6/16/2006 7:28:58 PM GMT
  • Bstamp_gpsBstamp_gps Posts: 9
    edited 2006-06-16 20:59
    That's right. The XOR calculation is after "$" and before "*".
    I've looked at that website. However, what I need to know is how can we do this with Basic Stamp?

    Thanks.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-06-16 22:17
    Someone will come along with something bright & bouncy, but in the meantime I'll offer the plodding and obvious:

    The character G has an ascii value of $47,· % 0100 0111
    The character P has an ascii value of $50,· % 0101 0000
    The character R has an ascii value of $52,· % 0101 0010

    ^ is the operator for bitwise XOR

    chksum = 0100 0111 ^ 0101 0000····· ' G xor P
    (this results chksum = 0001 0111)

    chksum = chksum ^ 0101 0010········ ' (G xor P) xor R
    (this results chksum = 0100 0101)

    So, you convert your ascii characters to their byte/numeric equivalent and start your checksum DO... LOOP (FOR... NEXT, whatever you like) process (re. above)

    Y/N ?

    PS -- Remember to XOR the commas, too.
  • Bstamp_gpsBstamp_gps Posts: 9
    edited 2006-06-16 23:06
    Thanks PJ. That confirms what I had in the back of my mind, although likewise - I was hoping it didn't have to be so "plodding". Anyway ... I'll give it a go over the weekend and let you know how I get along with Basic Stamp.

    Many thanks for your time ~
Sign In or Register to comment.