EasyManua.ls Logo

Globalstar STX3 - Page 27

Globalstar STX3
35 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
8545-0198-01 Revision 1.9 STX3 Users Manual
9/24/2020 Globalstar, Inc. Confidential and Proprietary Page | 23
The following example is written in the Java programming language:
char crc16_lsb(byte pData[], int length)
{
int pData_i = 0;
char s1,s2;
byte i;
char data, crc;
crc = (char) 0xFFFF;
if (length == 0)
return 0;
do
{
data = (char)((char)0x00FF & pData[pData_i++]);
crc = (char)(crc ^ data);
for (i = 8; i > 0; i--)
{
if ((crc & 0x0001) != 0)
crc = (char)((crc >> 1) ^ 0x8408);
else
crc >>= 1;
}
} while (--length != 0);
crc = (char)~crc;
return (crc);
}
USAGE: calculate the CRC for a message and update the message CRC
byte msg[]; int len;
char crc = crc16_lsb(msg,len-2);
msg[len-2] = (byte)((short)crc & (short)0xff);
msg[len-1] = (byte)((short)crc >> 8);

Other manuals for Globalstar STX3

Related product manuals