Appendix
MPT-7000V User Manual
91
2.
Protocol
⚫
Signal transmit format
Bandwidth
Baud rate: 19200 bps
Data Format
Parity: No Parity
1 start bit
8 data bits
1 stop bit
⚫
Packet Format
Header
Size
Command
Data
CRC
2 bytes
1 byte
1 byte
0
– 64 bytes
2 bytes
Header
bytes indicate start of the packet.
Size
specifies number of bytes for data field.
Command
identifies action, which is required to be performed on the
data.
CRC
verifies data integrity for header, size, command and data bytes.
⚫
CRC
Protocol uses 16-bit CCITT CRC to verify data integrity.
P(x) = X
16
+X
12
+X
5
+1
unsigned
calc_crc(
unsigned char
*data,
unsigned
n,
unsigned
start) {
unsigned
I, k, q, c, crcval;
crcval=start;
for
(I=0; I<n; I++) {
c=data(I) & 0xFF;
q=(crcval^c) & 0x0F;
crcval=(crcval>>4)^(q*0x1081);
q=(crcval^(c>>4)) & 0x0F;
crcval=(crcval>>4)^(q*0x1081);
}
return
crcval;
}