
Page 72
APPENDIX B Modbus RTU C Code Example
Data Reception and CRC Generation & Checking
This is a simple C code example for packet generation and the checking of Modbus RTU Protocol.
Request Packet Generation
Main module, Read Holding Registers Request Example
#define CRC_16 0xA001
unsigned int Crc Table[256];
main()
{
unsigned char send_byte[12];
unsigned short crc_out;
MakeCrcTable(CRC_16);
send_byte[0]= 0x01
send_byte[1]= 0x03
send_byte[2]= 0x00;
send_byte[3]= 0x64;
send_byte[4]= 0x00;
send_byte[5]= 0x02;
crc_out=MakeCrc(send_byte,6);
send_byte[6]= ( crc_out >> 8 )& 0xFF;
send_byte[7]= crc_out & 0xFF;
}
Summary of Contents for ACCURA 7500
Page 6: ...Page 6 Standard Compliance Process Control Equipment E324900...
Page 75: ......