Contact us: PhonePhone EmailEmail

Calculating the Checksum of an API Packet

The API operation of the radios (XTend and XBee) requires that communication through the UART or serial port of the radio be done through a structured interface where data is communicated in formatted hexadecimal frames. New frames begin with the delimiter 7E. Consider the following sample data packet.


7E 00 0A 01 01 50 01 00 48 65 6C 6C 6F B8



7E
Start Delimeter
00 0A
Length Bytes
01
API Identifier
01
API Frame ID
50 01
Destination Address low
00
Option Byte
48 65 6C 6C 6F
Data Packet
B8
Checksum

To calculate the check sum you add all bytes of the packet  excluding the frame delimiter 7E and the length (the 2nd and 3rd bytes).


7E 00 0A 01 01 50 01 00 48 65 6C 6C 6F B8


Add these Hex bytes:

01 + 01 + 50 + 01 + 00 + 48 + 65 + 6C + 6C + 6F = 247


Now take the result of 247 and keep only the lowest 8 bits which in this example is 47 (the two far right digits). Subtract 47 from FF and you get B8 (FF - 47 = B8). B8 is the checksum for this data packet.


If an API data packet is composed with an incorrect checksum, the radio will consider the packet invalid and the data will be ignored.


To verify the check sum of an API packet add all bytes including the checksum (do not include the delimiter and length) and if correct, the last two far right digits of the sum will equal FF.


01 + 01 + 50 + 01 + 00 + 48 + 65 + 6C + 6C + 6F + B8 = 2FF



 

 

Privacy Policy | Terms & Conditions | Contact Us | Careers | Site Map | Newsletter Signup | Feedback
Copyright © 1996-2010 Digi International Inc. All rights reserved.
Facebook YouTube