Home/Support/Support Forum/How do I stop the program from giving me the "length is not 8 bytes" error in python?
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

How do I stop the program from giving me the "length is not 8 bytes" error in python?

0 votes
So, I set up and end device and API coordinator (trying to make a larger network), and I want to program the coordinator to extract the correct sender address so the coordinator can talk back to the end device. I figured out a lot of string formatting stuff, and I saved the final formatted string as long_add. When I print long_add, the following prints:

\x00\x13\xa2\x00\x40\x71\x04\x1c

But when I put dest_addr_long = long_add in the transmit function, it returns the error "destination address was not 8 bytes long" even though it CLEARLY is...
What's even weirder is, when I copy and paste the above printed out long_add into the transmit function as des_addr_long="\x00\x13\xa2\x00\x40\x71\x04\x1c", the code runs! It makes absolutely no sense! The type of long_add is also string; I checked all of this. The transmit function is in the same format as all of the examples/as the end device program that sends data successfully... I'm just so lost right now- I'd be so grateful to anyone who can help.
asked Jun 23, 2014 in Python by gabraha1 New to the Community (0 points)

Please log in or register to answer this question.

2 Answers

0 votes
what firmware are you running? Is this ZB, 802.15.4, Digi Mesh, etc?

The app is running on your PC? Which is connected to the coordinator?

Just trying to understand your setup.
answered Jun 26, 2014 by kjensen8 Veteran of the Digi Community (653 points)
I have the coordinator connected to a BeagleBone and programmed to continuously read data from end devices on the network (the coordinator just runs a python program I wrote and saved to the BeagleBone). I have the end device hooked up to a computer running through XCTU. I send packets manually via XCTU. The problem isn't with the setup- python is extracting the address wrong (converting some random hex values into ASCII and leaving others unchanged). And when I type in an address to the tx function, it works, but when I have the BeagleBone extract the address, there's a runtime error in the program despite that the address prints out correctly...
0 votes
This post can solve your problem .

Assume, you are having following scenario .

source_addr =

source_addr_long =
# Coordinator transmit packet to any router .

# Decision can be taken at run time by coordinator.

# One to many nodes transmission is thus possible.

xbee1.tx(
frame='0x1'
, dest_addr=bytearray( int(x,16) for x in source_addr)
, data='Hi'
, dest_addr_long= bytearray( int(x,16) for x in source_addr_long)
)

# It will Work . Go to very basic thing .

# string to int , int to hex , hex to int .

hex(19) => '0x13'

int('0x13',16) => 19

x = '0x13'

then int(x,16) will be 19
answered Mar 8, 2015 by bnmahajan78 New to the Community (1 point)
...