7-5
Chapter 7. CPL Communication Function
• ETX
ETX indicates the end of the application layer.
• Checksum
This value is for checking whether something abnormal (e.g., electromagnetic
noise) has caused the message content to change during transmission.
The checksum is expressed as a 2-digit hexadecimal character code.
• How to calculate a checksum
(1) Add the character codes in the message from STX through ETX in single
byte units.
(2) Take two's complement of the low-order one byte of the sum.
(3) Convert the obtained two's complement to a two-byte ASCII code.
The following is a sample checksum calculation:
Sample message
STX : 02H
0: 30H (1st byte of the station address)
1: 31H (2nd byte of the station address)
0: 30H (1st byte of the sub-address)
0: 30H (2nd byte of the sub-address)
X: 58H (device ID code)
R: 52H (1st byte of the command)
S: 53H (2nd byte of the command)
(omitted)
ETX : 03H
(1) Add the character codes in the message from STX through ETX in single
byte units. The addition calculation in single byte units is as follows:
02H + 30H + 31H + 30H + 30H + 58H + 52H + 53H + ... + 03H
The result of this calculation is 376H.
(2) The low-order byte of the sum, 376H, is 76H. The two's complement of
76H is 8AH.
(3) Convert the obtained 8AH to a two-byte ASCII code.
The result is:
8: 38H
A: 41H
The two bytes, 8 (38H) and A (41H), are the checksum.
• Delimiter (CR/LF)
This indicates the end of the message. Immediately after LF is received, the device
enters a state allowed to process the received message.