Serial Communication
112
© SICK AG • Subject to change without notice. • 8017035/ZMO9/2017-06-08
8.1.3
Command Format
All sent and received commands are communicated in the following format.
Label
STX
Data length
Command
Data part
ETX
Checksum
Number of bytes
1
1
2
0 to 510
1
1
Number of bytes Data
Details
STX
1
STX (02h)
—
Data length
1
The length of the data is written in units of words. (1 word = 2 bytes)
Command
2
Communication command
Data part
0 to 510
ETX
1
ETX (03h)
—
Checksum
1
The value resulting from the XOR calculation of the values from STX
to ETX (excluding STX and ETX)
Tips: • One response is always returned for each command. If communication
is performed correctly, the same command as that which was sent
will be returned. If an error occurs during communication, the error code
will be returned.
Command
02
00
20
1b
03
?
Description
STX
Length
Command
ETX
Sum
1.
The XOR calculation is performed on the value of each byte excluding
STX and ETX.
00: 00000000
20: 10000000
1b: 00011011
— — — — — — —
10011011
→
0x3b
* XOR calculation: Each binary digit is compared. If the number of 1s
is odd, the result is 1. If the number of 1s is even,
the result is 0.
Tips: • You can even use Calculator in the Windows
®
Accessories folder to perform this calculation.
•
By changing Calculator to “Programmer”
(“Scientific” in Windows
®
XP or Vista) mode,
you can perform calculations in hexadecimal and
switch between hexa decimal and binary notations.
You can also perform “XOR” calculations.