Calculate And Verify Checksums - Digi XBee XTC User Manual

Digimesh radio frequency (rf) module
Hide thumbs Also See for XBee XTC:
Table of Contents

Advertisement

Operate in API mode
Start
delimiter
1
0x7E
MSB
Frame type is the API frame type identifier. It determines the type of API frame and indicates
n
how the Data field organizes the information.
Data contains the data itself. This information and its order depend on the what type of frame
n
that the Frame type field defines.
Checksum
Checksum is the last byte of the frame and helps test data integrity. It is calculated by taking the hash
sum of all the API frame bytes that came before it, except the first three bytes (start delimiter and
length).
The device does not process frames sent through the serial interface with incorrect checksums, and
ignores their data.

Calculate and verify checksums

To calculate the checksum of an API frame:
1. Add all bytes of the packet, except the start delimiter 0x7E and the length (the second and
third bytes).
2. Keep only the lowest 8 bits from the result.
3. Subtract this quantity from 0xFF.
To verify the checksum of an API frame:
1. Add all bytes including the checksum; do not include the delimiter and length.
2. If the checksum is correct, the last two digits on the far right of the sum equal 0xFF.
Example
Consider the following sample data packet: 7E 00 0A 01 01 50 01 00 48 65 6C 6C 6F B8+
Byte(s)
7E
00 0A
01
01
50 01
00
XBee®/XBee-PRO XTend Compatible (XTC) DigiMesh RF Module User Guide
Frame
Length
type
2
3
4
API frame type
LSB
Description
Start delimiter
Length bytes
API identifier
API frame ID
Destination address low
Option byte
Frame data
Data
5
6
7
8
9
...
Data
API mode overview
Checksum
n
n+1
Single byte
61

Advertisement

Table of Contents
loading

This manual is also suitable for:

Xbee-pro xtc

Table of Contents