Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Every API frame begins with a start byte. This is a unique number that indicates we are at the beginning of the data frame. In our hypothetical example above, we used decimal 255 for this. The XBee API employs decimal 126 for the exact same purpose. Because everything in the API documentation is described in hexadecimal format, we’ll do that here, too. Remember that hex is just notation: decimal 126 and 0x7E are exactly the same number, just written down in different styles. (If you need to brush up on hexadecimals, this is a good time to flip back to the sidebar Hexadecimals in Chapter 2.)
If we start reading bytes that are arriving from the XBee’s serial port in midstream, we won’t know what they represent until we know their order. So the first thing to do is look for a start byte of 0x7E. Once we get that, we know where we are and everything else can fall into place. The start byte is like the front cover of a book.