PySerial Data Received From XBee Not Properly Displayed
I am trying to get multiple XBees running as sensors and output devices to send their samples to a coordinator XBee hooked up as below and to turn things on and off on these remote
Solution 1:
As a matter of fact @ is \x40. And y is \x79. So the "values" are correct...
>>> '\x13\xa2\x00\x40\x79\xe6\x5f' == '\x13\xa2\x00@y\xe6_'
True
If it is only a matter of formatting, you could use something like that to pretty display your addresses:
>>> value = '\x13\xa2\x00@y\xe6_'
>>> pretty_value = ':'.join("{:02X}".format(ord(c)) for c in value)
>>> print(pretty_value)
13:A2:00:40:79:E6:5F
On the other hand, it seems to me that you are off by one byte while accessing the address:
Expected: \x13\xa2\x00\x40\x79\xe6\x5f
Actual value: \x00\x13\xa2\x00\x40\x79\xe6
One possible reason is that you missed tha fact that in API 2 mode some characters could be escaped. So changing the actual offset of the various fields in the data frame. Since you are using a library, are you sure it handle properly API 2 mode? Is it correctly configured to do so?
Concerning your frame:
7E 00 16 92 00 13 A2 00 40 79 E6 5F DF 13 01 01 00 40 09 00 40 02 04 02 07 2E
Just decoding the first fields fields of the header:
- This is a 0x92 "IO Sample Rx" frame of 16 bytes long.
- The source address 64 bits is 00:13:A2:00:40:79:E6:5F
- The source address 16 bits is DF:13
- The packed was acknowledged (0x01)
Post a Comment for "PySerial Data Received From XBee Not Properly Displayed"