User's Manual

Table Of Contents
Interfaces
22 DUST NETWORKS M2135-1/M2030-1 MOTE DATASHEET
CONFIDENTIAL
7.3.5 HDLC Packet Processing Examples
Example 1: Constructing an HDLC packet to send to the mote
This example demonstrates how you would construct an HDLC packet to set the network ID value to 125. (All values are in
hexadecimal.)
Step 1 Define HDLC packet payload:
Command type => 87
Parameter => 01
Network ID => 7D
Step 2 Calculate FCS:
a. Calculate the FCS using FCS-16 algorithm (RFC 1662) on the hexadecimal sequence '87 01 00 7D'.
The FCS (including 1's complement) is 74 2F.
b. Append FCS to payload, FCS is sent least significant byte first (RFC 1662):
Step 3 Perform byte stuffing.
To perform byte stuffing, check the HDLC Packet Payload and FCS for instances of “7D” or “7E” and replace as
follows:
7D => 7D 5D
7E => 7D 5E
Note that the additional control bytes do not count against the 80-byte payload limit.
Step 4 Add start and stop delimiters:
Enclose the above in start/stop flags (RFC 1662).
Or simply, the hexadecimal sequence:
7E 87 01 00 7D 5D 2F 74 7E
Example 2: Decoding an HDLC packet received from the mote
To understand how to decode an HDLC packet sent from the mote, let’s assume that the mote received a “get mote
information” command, and replied with the following HDLC Packet. (All values are in hexadecimal.)
Step 1 (HDLC layer) strip off delimiters:
HDLC Packet Payload
Command Type Message Content
87 01 00 7D
HDLC Packet Payload FCS
87 01 00 7D 2F 74
HDLC Packet Payload (stuffed) FCS (stuffed)
87 01 00 7D 5D 2F 74
Start Delimiter HDLC Packet Payload (stuffed) FCS (stuffed) Stop Delimiter
7E 87 01 00 7D 5D 2F 74 7E
Start Byte HDLC Packet Payload (stuffed) FCS (stuffed) Stop Byte
7E 8A 07 00 1F 00 00 5B 00 01 01 06 00 3C 00 00 00 00 00 00
7D 5E C3 02 00 08 30 30 30 5F 45 56 30 31 00 13 00
43 47 7E
HDLC Packet Payload (stuffed) FCS (stuffed)
8A 07 00 1F 00 00 5B 00 01 01 06 00 3C 00 00 00 00 00 00
7D 5E C3 02 00 08 30 30 30 5F 45 56 30 31 00 13 00
43 47
PRELMINARY