Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 250f86d0d4
Fetching contributors…

Cannot retrieve contributors at this time

31 lines (20 sloc) 0.652 kb
// calculate a CRC for the line of input
// tested against http://nmeachecksum.eqth.net/
void do_crc(char *pch)
{
unsigned char crc;
//PString CRC_buf(buf, sizeof(buf));
if (*pch != '$')
return; // does not start with '$' - so can't CRC
pch++; // skip '$'
crc = 0;
// scan between '$' and '*' (or until CR LF or EOL)
while ((*pch != '*') && (*pch != '\0') && (*pch != '\r') && (*pch != '\n'))
{ // checksum calcualtion done over characters between '$' and '*'
crc ^= *pch;
pch++;
}
// add or re-write checksum
//sprintf(pch,"*%02X\r\n",(unsigned int)crc);
Serial.println((unsigned int)crc,HEX);
}
Jump to Line
Something went wrong with that request. Please try again.