niolabs / python-xbee

Python tools for working with XBee radios
MIT License
101 stars 45 forks source link

Possible issue in long adress source #7

Closed darrepac closed 8 years ago

darrepac commented 8 years ago

Hi

I am just giving a try to your library. So far I have tested communication between my 2 XbeePro devices, it works well. I am sending data from a device which adress is: 00 13 A2 00 40 E9 A9 4A

With your library, I am just printing the received frame and I got: 'source_addr_long': '\x00\x13\xa2\x00@\xe9\xa9J'

It seems that the library (or pyserial underneath) is formatting some values into caracters "@" = 0x40 "J" = 0x4A

would be nice to correct it.

darrepac commented 8 years ago

I have the same issue with RSSI: value is moving from 7 to 9 and then ":", ";" or "<". I guess it is for 10, 11, 12 but that's not explicit! how can it be corrected?

mrozaini commented 8 years ago

from my understanding, all the data will represent in ASCII not in hex. Some of your data represent in hex because that value has no meaning in ASCII that why it display in hex. To make it sync maybe u can try this. By converting all the data in hex and you will get all the data in hex.

address = data['source_addr_long'] print address.encode("HEX")

hope this will help both of you.

hansmosh commented 8 years ago

@darrepac, what @mrozaini said is correct. You're printing some bytes and Python is trying to print them as the ascii characters represented by those bytes (if it knows how). Google "ascii table" and you'll see that 0x40 is "@".

If you print the hex encoded version of those bytes (as opposed to the default ascii encoded value), you'll see the values you are expecting.