
MULTI GAUGE CONTROLLER
COMMUNICATION
CRC CHECKSUM CALCULATION - EXAMPLE IN C LANGUAGE
The example uses data of ”uint ” and ”uint ” types. The signs correspond, in turn, -bit integer
number without sign (usually for most types of compilers ”unsigned short int”) and -bit integer
number without sign (”unsigned char”). ”z_p” indicates Modbus data messages, and ”z_message_length”
means their length without CRC checksum.
uint16 calculate_crc
(
char
*
z_p
,
uint16 z_message_length
)
/* CRC runs cyclic Redundancy Check Algorithm on input z_p */
/* Returns value of 16 bit CRC after completion and */
/* always adds 2 crc bytes to message */
/* returns 0 if incoming message has correct CRC */
{
uint16 next
,
carry
,
n
,
CRC
= 0
xffff
;
uint8 crch
,
crcl
;
while
(
z_message_length
--) {
next
= (
uint16
)*
z_p
;
CRC
^=
next
;
for
(
n
= 0;
n
< 8;
n
++) {
carry
=
CRC
& 1;
CRC
>>= 1;
if
(
carry
) {
CRC
^= 0
xA001
;
}
}
z_p
++;
}
crch
=
CRC
/ 256;
crcl
=
CRC
% 256
z_p
[
z_message_length
++] =
crcl
;
z_p
[
z_message_length
] =
crch
;
return
CRC
;
}
. .
MODBUS TCP
The MG supports the Modbus TCP protocol via Ethernet connection. It is a protocol version used
for communication in TCP/IP networks. The connection is executed in port
by default. The
checksum is not placed in the frame, due to the fact that the lower layers of the TCP/IP protocol
ensures error control and identi ication of the device.
. . .
CONNECTION PARAMETERS
All the interface parameters are saved in the non-volatile memory of the MG . The DHCP protocol
option is enabled by default and the device should be assigned with the last parameters such as an
IP address, subnet mask and network default gate address.
The MG supports standard “ping” tool to test the connection. Other protocols such as http, ftp or
telnet are not supported.
. . .
PARAMETER SETTINGS
In the event when the device must have a permanent, previously established IP address, this can
be done by changing the parameters in the device menu, see subchapter . . . In case of a de-
vice without a display (BlackBox) transmission parameters for the Modbus TCP protocol can be
changed through the communication interface RS
/
. For this purpose, send appropriate
commands described in table . . . After every change of the parameters the Ethernet interface
will be restarted.
User manual rev.
Page