UPS2000-(6 kVA-20 kVA)
Modbus Protocol Development Guide
1 Communication Protocol
Issue 02 (2016-03-10)
Huawei Proprietary and Confidential
Copyright © Huawei Technologies Co., Ltd.
9
1.5 Command Type and Format at the Application Layer
1.5.1 Function Code List
Function Code
Meaning
Remarks
0x03
Read command
Continuously read a single
or multiple registers.
0x06
Write single register
command
Write commands to a single
register.
0x2B
Read device identifier
command
N/A
1.5.2 CRC Checking Algorithm
unsigned short count_CRC(unsigned char *addr, int num)
{
unsigned short CRC = 0xFFFF;
int i;
while (num--)
{
CRC ^= *addr++;
for (i = 0; i < 8; i++)
{
if (CRC & 1)
{
CRC >>= 1;
CRC ^= 0xA001;
}
else
{
CRC >>= 1;
}
}
}
return CRC;
}