Python xbee module, setting panID

I’m running python scripts on a Digi ConnectPort X4 yet am unable to set a device’s panID using the xbee module’s ddo_set_param()

In the ConnectPort X4’s web control panel, I can see that the device is on my network in the XBee Network tab. Through the web interface, I can set it’s panID to, say, 0x1122334455667788. It then disappears from my XBee Network, as expected. I can then set the panID of my ConnectPort X4 to 0x1122334455667788 and shortly after the device reappears on my network, again, as expected.

However, I don’t seem to be able to this via a python script.

What does the xbee.ddo_set_param(addr, “ID”, input ) function expect as input ?

I’ve tried running the following command :


import xbee
xbee.ddo_set_param("[00:13:a2:00:40:70:75:e0]!", "ID", int("0x1122334455667788", 16))

But get the following error :


Traceback (most recent call last):
  File "", line 1, in ?
TypeError: ddo_set_param: value must be an integer or string!

The problem being that int(“0x1122334455667788”, 16) returns a long. Of course, you can’t represent the panID as an integer as it has a range of 0 to 0xFFFFFFFFFFFFFFFF. So I’d logically need to specify it as a string.

However, I’ve tried the following and got the following errors :


>>> import xbee
>>> xbee.ddo_set_param("[00:13:a2:00:40:70:75:e0]!", "ID", str(int("0x1122334455667788", 16)))

Traceback (most recent call last):
  File "", line 1, in ?
Exception: ddo_set_param: error setting DDO parameter.

>>> xbee.ddo_set_param("[00:13:a2:00:40:70:75:e0]!", "ID", "0x1122334455667788")

Traceback (most recent call last):
  File "", line 1, in ?
Exception: ddo_set_param: error setting DDO parameter.

>>> xbee.ddo_set_param("[00:13:a2:00:40:70:75:e0]!", "ID", "1122334455667788")

Traceback (most recent call last):
  File "", line 1, in ?
Exception: ddo_set_param: error setting DDO parameter.

What does the xbee.ddo_set_param(addr, “ID”, input ) function expect as input ?

Also, just as proof that my error isn’t in the connection between the CP X4 and the device, I can set the node identifier using the following :


>>> import xbee
>>> xbee.ddo_set_param("[00:13:a2:00:40:70:75:e0]!", "NI", "BBB-106")
True

And the new name “BBB-106” shows up in the CP X4’s web based admin panel.

Hi,

The value what you are providing to ID parameter is very large, ddo_set_param can only take int or string as input.

Create a Online Support Request at the following link, http://www.digi.com/support/eservice , Digi Technical folks will be able to help you regarding this.

The value what you are providing to ID parameter is very large, ddo_set_param can only take int or string as input.

Yes, it’s very large. As I’ve said, that’s to be expected : it’s 8 hex bytes, so can be anywhere from 0 to 0xFFFFFFFFFFFFFFFF

Hello. There is a work-around for this problem.

You can pack the larger integer into a string. This should work just fine for you:

import xbee
import struct
s = struct.pack(‘q’, 0x1122334455667788)
xbee.ddo_set_param(‘[00:13:a2:00:40:2d:ce:64]!’, ‘ID’, s)

Please try this and let me know if it works for you.

Thanks,
Nathan Fritsche
Digi International
iDigi Systems Engineer

Nathanf’s ‘solution’ needs one small fix to be ‘perfect’: upper-case Q as format (unsigned long long), otherwise a PANID with the most significant bit set will fail to convert:

import xbee
import struct
s = struct.pack(‘Q’, 0xF122334455667788)
xbee.ddo_set_param(‘[00:13:a2:00:40:2d:ce:64]!’, ‘ID’, s)