Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

NMEA checksum or C to CF translation

Guest
Jun 16, 2006 Jun 16, 2006
Please help me some math or C gurus,
I am in no way a math or C expert and this has made realy huble.

My system calculates checksums based on the National Marine Electronics Association standard. The standard is supported by most GPS systems. I need to generate a hexadecimal number using the checksum of a string according to this and attached C code as an example.

The format of an NMEA sentence is as follows:
$GPRMC,235947.000,V,0000.0000,N,00000.0000,E,,,041299,,*1D<Carriage return>
The checksum immediately follows the ‘*’ (asterisk) character and is computed by taking the bit-wise exclusive-OR of all characters between the ‘$’ (dollar sign) and the ‘*’ (asterisk). The checksum is represented in hexadecimal and is 1D (decimal 29) for the example sentence above.

The following standard C code demonstrates the checksum calculation.
#include <stdio.h>
unsigned char calc_checksum(const char *s)
{
unsigned char result;
result = 0;
s++; // Skip dollar sign
while ((*s != '*') && (*s != '\0'))
result ^= *s++;
return result;
}
int main()
{
unsigned char checksum;
checksum = calc_checksum ("$GPRMC,235947.000,V,0000.0000,N,00000.0000,E,,,041299,,*");
printf("Checksum = %02X\n", checksum);
return 0;
}
When executed, the program should produce the following output:
Checksum = 1D
Could some one help me translating this into CF, CF script or Javascript?
The rest I can do my self.

Bosse Persson
2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Jun 17, 2006 Jun 17, 2006
Use the attached code.

Translate
Guest
Jun 17, 2006 Jun 17, 2006
Use the attached code.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 18, 2006 Jun 18, 2006
Thank you MikerRoo,
I will try this out tomorrow at the office.
It looks really neat and I cant wait to try it!!!!
You have helped me to solve an overwelming problem if it works

I will be back tomorrow
Bosse
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 19, 2006 Jun 19, 2006
LATEST
One more thank you MikerRoo!
This is perfect and works 100% for me!

All the best

Bosse
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources