I changed the checksum and it worked! Many Thanks!
Do you know any VB.net ??, Here’s my calculation code, I believe I’m only supposed to use the lowest bit of the result?
' frame is ready now, calulate checksum
Dim CHECKSUM_TOTAL As Long = 0
Dim WRITE_BUFFER(HEX_FRAME_AT_COMMAND.Count) As Byte
Dim POS As Integer
' process hex frame and calculate total checksum
For POS = 0 To HEX_FRAME_AT_COMMAND.Count - 1
WRITE_BUFFER(POS) = Convert.ToByte(HEX_FRAME_AT_COMMAND(POS), 16)
CHECKSUM_TOTAL += WRITE_BUFFER(POS)
Next
' set checksum
CHECKSUM_TOTAL = CHECKSUM_TOTAL - WRITE_BUFFER(0) - WRITE_BUFFER(1) - WRITE_BUFFER(2) ' exclude first 3 bytes
Dim LOWEST_BIT As Integer = CHECKSUM_TOTAL Mod &HFF
Dim CHECKSUM As Integer = &HFF - (LOWEST_BIT)
' set checksum
WRITE_BUFFER(POS) = CByte(CHECKSUM)
I do now recall that when I got the Range test working only the XBee connected to the PC was using API commands. The other unit, that had the loop-back, was in AT command mode.
You can not loop-back the serial lines of the XBee when it uses API. The output frames are not the same as the input frames therefore they will be ignored.
The network includes temperature, light and humidity sensors in the house, attic, garage and nursery (trees). Some are End devices other are Routers.
There is also a node on my robot with status and commands to/from the PC.
I started with a Digi connect box that allowed remote access from the internet but found this to be unneeded. Now the Coordinator is direct to a 115kbps RS232 Comm port and a Python script handles the interface.
My next project is a handheld ZigBee terminal to get status from any sensor. And I would like to add some XBees to control a few things around the house.
I’m experimenting with some UAV stuff, and would really like to use the Xtend device (it’s 900Mhz) and thats illegal in UK, so stuck with 2.4Mhz setup.
Ever had a problem reading a split data packet from your serial read?
The first thing I check is for byte 0 to be 0x7E (start delimiter), but sometimes it’s not, because the previous packet was not a full one, but split, some the current packet is the last X bytes of the previous one?
It’s feels like a serial problem, but it could be the transmitting Xbee setup??
I always fully buffer the data out of an XBee then parse out of the data buffer. On the PC the COM driver does the Port buffering and I pull one value at a time. Once the 0xFE, Start of Frame, is obtained then the entire frame is brought in and parsed including comparing the Checksum. The Data Payload is parsed out into a ring buffer for its target Task to use. This allows discontinuous Data Payloads as the Ring buffer is filled by one pointer and emptied by a second pointer. If the Task does have all the data yet and the Ring buffer is Empty, getting the next value is pending, Task waits for more data.
Ring buffer code is intimidating at first but once you write and use a few you’ll use them for many communication tasks. They do decouple the hardware pieces from the software pieces and removes many timing constraints.
waltr:
Ring buffer code is intimidating at first but once you write and use a few you’ll use them for many communication tasks. They do decouple the hardware pieces from the software pieces and removes many timing constraints.
On the AVRfreaks.net forum, projects section, there are many code samples that use ring buffers.
I don’t bother with the checksum because 802.15.4 has CRC checking for bit errors, with retransmission, etc.