Electronic – Doubts on Implementing a Simple Protocol for XBee Comms

communicationrs232serialxbee

A system that I'm developing will use XBee modules for a point to point connection between a micro-controller and a PC. Data will only be sent only in one direction -Micro to PC and at 10-20fps. The data portion of each frame will be 4 Bytes. XBee modules will be run in transparent mode(to begin with at least). On the PC side I'm using python to grab the data from the serial port.

Initially I wrote a very simple python program to grab data 4 Bytes at a time from the serial Port, which worked fine when tested with a virtual com connection (I haven't run any real world tests yet though), but I decided to experiment and ended up implementing a simple frame structure like this.

sync_flag | Payload_length | frame_number | payload

After some research I discovered HDLC and now I'm considering implementing something similar albeit simpler. Before I endeavor to do so Id like to hear what others have to say.

When is such a protocol merited?

What have you done when you implemented your XBee networks?


Being somewhat new to this area I'm sure there's some relevant specifics Iv left out, but at the same time I didn't want to make the question too narrow / system specific, but if necessary Ill update the question.

Best Answer

I'm going to be using Xbee modules. I'll be trying to use a point to multipoint network.

At the moment, I plan to have a transmitter identifier, payload type, payload length, payload and checksum - it would look something like this:

Field            Type    Description   
transmitter_id   uint8   Identifies the transmitting module (0-255)
type             uint8   Type of data (GPS coordinates, hit status, etc.)
length           uint8   Length of payload in bytes
payload          -       Actual payload
checksum         uint16  CRC16 of everything before

That's how I imagine it, the format might change but this will be the basic protocol in use.