Command protocol
Leuze electronic
DCR 55
63
9
Command protocol
Each device has a well-defined protocol for communication. The protocol can be split into two parts:
• General command/response-type communication
• Barcode decoding
9.1
General commands
Most of the time, the user will use the command protocol when communicating with the device. The figure
shows the general command sequence for sending a command to the device.
Fig. 9.1:
General command sequence
• The host device sends a properly formatted command to the device.
• The device sends an acknowledgement to the host device.
• Immediately after the acknowledgement, the device sends a response to the command.
• To maintain communication integrity, the host device sends an acknowledgement back to the device.
9.1.1
Command packet
To send a command to the device, a properly formatted packet must be formed.
Tab. 9.1:
Command packet format
Section
Bytes (or Range) Number of
Bytes
Description
Start of Frame
0x01
0x43
0x54
3
Three bytes that indicate the beginning of a
message
Packet Version
0x31
1
Indicates the version number for the packet
format. This value is always 0x31.
Packet Length
0x0013 – 0xFFFF 2
Indicates the number of bytes that are sent
after these two bytes, up to and including the
CRC. This value should be 19+N.
This value is written as a 2-byte big endian
value.
Destination Address
0x00000000 –
0x0FFFFFFF
4
Represents the address of the device that
you are attempting to communicate with.
0x0FFFFFFF is a special address indicating
that the host device wants to broadcast to all
devices on the network. Anything less than
this value is a real device address.
This value is written as a 4-byte big endian
value.