Home > Software engineering > Turn to stick: MFC PC serial port to send data to add two bytes of crc16 check
Turn to stick: MFC PC serial port to send data to add two bytes of crc16 check
Time:09-21
Crc16 calibration algorithm code, but not with, Purpose: it is need to take before 14 bytes of data (hexadecimal) to calculate two bytes of crc16 check (hexadecimal), and then sent along to the next bit machine, code is c + + MFC,
Novice, a headache for a long time, oneself also baidu for a long time, just can't write, hope god can give a reference code, or advise me, thank you ~
CodePudding user response:
/* * * * * crc16. H * * * * */ //* # define CRC16_DNP 0 x3d65//DNP, IEC 870, M - BUS, wM - BUS,... # define CRC16_CCITT 0 x1021//x. 25, v. 41, in HDLC FCS, Bluetooth,...
# define POLYNOM CRC16_XXX//define the informs the POLYNOM from one of the aboves
//It calculates the new crc16 have the newByte. Variable crcValue is the actual or initial value (0). Unsigned int crc16 (unsigned int crcValue, unsigned char newByte);
/* * * * * crc16. C * * * * */
# include "crc16. H"
Unsigned int crc16 (unsigned int crcValue, unsigned char newByte) { Unsigned char I;