Chauvin Arnoux ULYS FLEX Modbus Notice De Fonctionnement page 43

Table des Matières

Publicité

Les langues disponibles

Les langues disponibles

CRC GENERATION FUNCTIONS - Without Table
unsigned short ModBus_CRC16( unsigned char * Buffer, unsigned short Length )
{
/* ModBus_CRC16 Calculatd CRC16 with polynome 0xA001 and init value 0xFFFF
Input *Buffer - pointer on data
Input Lenght - number byte in buffer
Output - calculated CRC16
*/
unsigned int cur_crc;
cur_crc=0xFFFF;
do
{
unsigned int i = 8;
cur_crc = cur_crc ^ *Buffer++;
do
{
if (0x0001 & cur_crc)
{
}
else
{
}
}
while (--i);
}
while (--Length);
return cur_crc;
}
MODBUS RTU/ASCII
cur_crc >>= 1;
cur_crc ^= 0xA001;
cur_crc >>= 1;
43

Publicité

Table des Matières
loading

Table des Matières