Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to calculate the checksum of a NMEA sentence?

Status
Not open for further replies.

UroBoros

Advanced Member level 2
Joined
May 5, 2004
Messages
642
Helped
19
Reputation
38
Reaction score
8
Trophy points
1,298
Location
Cochin - India
Activity points
6,463
nmea crc

Hai

Inorder to input a command to my GPS module I want to calculate the checksum of that NMEA sentence. How to do that?

Any software available to calculate the checksum of a sentence?

Or how to that manually?

With regards

picstudent
 

how to calculate nmea input checksum

Calculating and Validating NMEA Checksums
Error correction and detection in NMEA data is handled through the use of checksums. A checksum is a two-character hexadecimal number, located at the end of each NMEA sentence, representing the "two's complement" of the sentence:


$GPGSA,A,2,29,19,28,,,,,,,,,,23.4,12.1,20.0*0F

In other words, each byte value between the dollar sign ($) and asterisk (*) is XOR'ed.

Attached is an example in C-code ..

Regards,
IanP
 

    UroBoros

    Points: 2
    Helpful Answer Positive Rating
to calculate 8-bit checksum for a hexadecimal

Look at this :

{
char buffer[82],buff2[6];
uint8 i,crc,s;

snprintf(buffer,sizeof(buffer),
"$GPGGA," //MESSAGE ID
"%09.2f," //UTCTIME
"%09.5f," //LATITUDE
"%c," //N/S Indicator
"%011.5f," //LONTITUDE
"%c," //E/W Indicator
"%d," //Type of fix
"%d," //Number of SV
"%.2f," //HDOP
"%.1f,M," //MSL Altitude
"%.1f,M," //GEOID Separation
",0" //DIFF Age, DIFF Station

,92725.00 //UTCTIME
,4717.11399 //LATITUDE
,'N' //N/S Indicator
,833.91590 //LONTITUDE
,'E' //E/W Indicator
,1 //Type of fix
,8 //Number of SV
,1.01 //HDOP
,499.6 //MSL Altitude
,48. //GEOID Separation
);

//Calculate crc...
crc=0; s=strlen(buffer);
for(i=1;i<s;i++)
crc^=buffer;

//Add it!
snprintf(buff2,sizeof(buff2),"*%02X\r\n",crc);
strcat(buffer,buff2);
}

Add the CRC definition for NMEA :

The NMEA checksum is an XOR of all the bytes (including delimiters such as ‘,’ but
excluding the * and $) in the message output. It is therefore an 8-bit and not a 32-bit
checksum for NMEA logs.

Chris. :D
 

    UroBoros

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top