The
I D
byte represents which command the request/response relates to.
There will be between 1 and 1023
Payl oad
bytes (inclusive) depending on the command type. Each command
under the
detailed command descriptions
section documents how the data bytes are used. The
I D
byte will always
be present in the payload, therefore the payload length has a minimumof 1.
The
CRC
bytes form a 16 bitchecksum value used to validate the integrityof the packet data. Every byte in the
packet except for the CRC itself is included in the checkum calculation.
7.3. Checksum
Each packet has a 2 byte checksum which is used to validate data integrity.The algorithmis
CRC-16-CCI TT
0x1021
(idendtical to the one used for the XMODEM protocol).
The CRC must be correctly formedfor the SF40/C to accept and process packets. Below are some examples in
various languages forCRC calculation:
C/C++
ui nt 16_t
ui nt 16_t
cr eat eCRC(
ui nt 8_t
ui nt 8_t
*
Data,
ui nt 16_t
ui nt 16_t
Si ze)
{
ui nt 16_t
ui nt 16_t
cr c =
0
;
f or
f or
(
ui nt 32_t
ui nt 32_t
i =
0
; i < Si ze;
++i)
{
ui nt 16_t
ui nt 16_t
code = cr c >>
8
;
code ^= Dat a[ i ] ;
code ^= code >>
4
;
cr c = cr c <<
8
;
cr c ^= code;
code = code <<
5
;
cr c ^= code;
code = code <<
7
;
cr c ^= code;
}
r et ur n
r et ur n
cr c;
}
SF40/C
Product manual
SF40/C -Product manual
|
14 of 30 |
© LightWare Optoelectronics (Pty) Ltd, 2019 |
www.lightware.co.za