I have just built an adapter which allows me to log the serial bytes going into my radios.
Here's what it has revealed:
Bytes from Arduino Xbee library:
Address: DH=0x0013a200, DL=0x4089e9a7
Command: D0=0x00
Frame: 7E 00 10 17 01 00 7D 33 A2 00 40 89 E9 A7 00 00 00 44 30 00 DD
Command: IR=0x00
Frame: 7E 00 10 17 01 00 7D 33 A2 00 40 89 E9 A7 00 00 00 49 52 00 B6
(No Response)
Address: DH=0x00000000, DL=0x00000000
Command: D0=0x00
Frame: 7E 00 10 17 01 00 00 00 00 00 00 00 00 00 00 00 44 30 00 73
Command: IR=0x00
Frame: 7E 00 10 17 01 00 00 00 00 00 00 00 00 00 00 00 49 52 00 4C
(Response OK)
Bytes from Python Module:
Address: DH=0x0013a200, DL=0x4089e9a7
Command: D0=0x00
Frame: 7E 00 10 17 00 00 13 A2 00 40 89 E9 A7 FF FE 02 44 30 00 67
Command: IR=0x00
Frame: 7E 00 11 17 00 00 13 A2 00 40 89 E9 A7 FF FE 02 49 52 00 00 40
(Response OK)
Address: DH=0x00000000, DL=0x00000000
Command: D0=0x00
Frame: 7E 00 10 17 00 00 00 00 00 00 00 00 00 FF FE 02 44 30 00 75
Command: IR=0x00
Frame: 7E 00 11 17 00 00 00 00 00 00 00 00 00 FF FE 02 49 52 00 00 4E
(Response OK)
By comparing the frames from Python to frames from Arduino for the same commands and address I can definitely see a discrepancy in the addressing:
Arduino: 7E 00 10 17 01 00 7D 33 A2 00 40 89 E9 A7 00 00 00 44 30 00 DD
Python: 7E 00 10 17 00 00 13 A2 00 40 89 E9 A7 FF FE 02 44 30 00 67
So I'm very convinced the Arduino Xbee library is outputting an erroneous address of some sort. But why?
[Edit]
Closer look at the address data:
[color=limegreen]00 1[/color][color=teal]3 A2 00 40 89 E9 A7[/color]
- Good Address (logged from Python)
[color=red]7D 3[/color][color=teal]3 A2 00 40 89 E9 A7[/color]
- Bad Address (logged from Arduino)
[color=limegreen]00000000_0001[/color][color=teal]0011_10100010_00000000_01000000_10001001_11101001_10100111[/color]
[color=red]01111101_0011[/color][color=teal]0011_10100010_00000000_01000000_10001001_11101001_10100111[/color]
Seems it all boils down to those first 12 bits?
[Edit]
I found that byte 13 (carriage return) behaves strangely whenever/wherever it is used in the destination address. I notice that where ever the byte 13 exists the output is always 7D 33 and the address gets totally botched.
For example:
If I set the destination address to:
XBeeAddress64 remoteAddress = XBeeAddress64(0x0014a200, 0x4089e9a7);
Then the output is:
7E 00 10 17 01 00 14 A2 00 40 89 E9 A7 00 00 00 44 30 00 64
But lets say I set the destination address to:
XBeeAddress64 remoteAddress = XBeeAddress64(0x0014a200, 0x1389e9a7);
Then the output is:
7E 00 10 17 01 00 14 A2 00 7D 33 89 E9 A7 00 00 00 44 30 00 91
And if I were ever unlucky enough to get a radio with many 13s in the address:
XBeeAddress64 remoteAddress = XBeeAddress64(0x0013a200, 0x13131313);
Then the output is:
7E 00 10 17 01 00 7D 33 A2 00 7D 33 7D 33 7D 33 7D 33 00 00 00 44 30 00 72
I have absolutely no idea where to even begin looking now but I believe I have found part of the problem.
Could this possibly have something to do with the Arduino Serial library or the fact that I'm using Serial1 and not Serial?