S
ENSOR
C
OMMANDS AND
R
ESPONSES
Copyright LMI Technologies Inc. 2003
19
N
UMERIC
F
ORMATS
The following describes the format of numbers contained within a packet.
Byte:
always an unsigned 8 bit number 0.255.
Words:
All words used in commands data streams are signed 16 bit numbers. When
using CRC, MSB of the data word is sent first ,When using Checksum LSB
of the data word is send first.
Decimal points are assumed, depending on data content and mode in which
sensor is set. I.e. if the data expected were in inches then 12345 would
represent 12.345". If the data expected is in millimeters then 12345 would
represent 1234.5 mm.
Some of the commands also require ASCII characters:
Byte:
8 bit ASCII
3.4
E
RROR
H
ANDLING
This section describes the
error handling of the serial communications at both the sensor and
the host.
3.4.1
S
ENSOR AND
H
OST
E
RROR
H
ANDLING
Sensor Error Handling
All packets transmitted to the sensor contains a Checksum or CRC as the last bytes.
The checksum is the 2s complement of the sum of all previous bytes sent in the packet starting
with the "STX" character and ending with the last data byte. As the sensor receives the packet
it sums all the bytes. The last operation of summing the checksum will result in a zero value.
If a non-zero result is obtained the data packet received was incorrect and will not be used.
The validity of the data in all packets transmitted to and from the sensor is checked using the
last byte of the packet as a Checksum or CRC.
H
OW DO
I
PROCESS A RECEIVED DATA PACKET
?
When receiving a data packet from the sensor, the host application should verify the validity of
the Checksum or CRC byte. Additionally, the application should ensure that the command
value returned matches the one sent in the request packet sent to the sensor.