Using Python to Access X4H Local Digital and Analog IO

Hi;

I see there are Phython modules, localdio and localain, for accessing the local digital and analog IO on an X4H but I do not see how I can make an instance of either. That is I assume I need to instantize the modules with something like this:

DIOlocal = localDIN(address)

But how do I get the address of the local IO ports?

In other words; for zigbee devices I can use ‘getnodelist()’ and get each device source arrdress. Is there an equivalent way to get the source address of the X4H IO?

You could likely check in the iDigi Dia src/devices/xbee/xbee_devices directory for the file xbee_local_aio_dio.py file and see how its done there.

I believe it imports the built-in digihw module, then uses that to instantiate:
http://www.digi.com/wiki/developer/index.php/Module:digihw

Another resource that might show this is the Python Drivers for Digi Adapters library. Inside is a DigiXBeeDrivers.zip file, which contains localain.py and localdin.py:
http://www.digi.com/support/productdetl.jsp?pid=3605&osvid=0&s=410&tp=10&tp2=0

So it seems the ‘digihw.py’ module is required to access the local IO (digital and analog) on the CP X4H. But I do not have a copy of this module. Could you point me to a link where I can get a copy?

Thanks

No, the digihw is a builtin, there is no .PY file - the import hooks into the interface between Python and the underlying OS directly.

Also, the Wiki page for digihw is woofully incomplete. It does not talk about these functions. Why not? I don’t know.

Download the DigiXBeeDrivers mentioned above.

Technically, the local ain/dio is handled by the coordinator XBee, so for any address asked for you’d use the gateway’s coordinator MAC. This should be hidden from you if you use the provided examples.

I have been attempting to use the localain.py and localdio.py modules with only limited success. Here is what I have experienced so far:

  1. The localain.py module has a ‘def calibration’ proc. From my testing it seems not to work, I get a key error, soI have just commented it out. Doing so has allowed the mod to work

  2. in the localain.py mod ther eis a proc:

digihw.get_channel_type(channel) != Analog:

OOPS sorry my last post was incomplete! So, getting back to 2.

What are the expected channel types? I see from the mod that channel type Analog is 1. What is value of channel type digital? and are there others?

  1. It seems I could use ddo_get and ddo_set to accomplish the same thing the localain.py and localdio.py modules do. Am I missing something here?

Thanks

Hello, I do not have an X4H to test this on, but you should be able to use the ddo_* methods just like you would on the XBee AIO/DIO (DIN) adapters.

Try copying the script below to your X4H and run from a telnet prompt to see what you get.

testX4h.py

import sys
sys.path.append(“WEB/python/DigiXBeeDrivers.zip”)
from sensor_io import parseIS
import zigbee

try:
result = zigbee.ddo_get_param(None, ‘IS’)
print parseIS(result)
except Exception, ex:
print ex

Thanks,
Nathan

Hello,
UPDATE: I had someone with an X4H try this script and it threw an exception. We will do some more testing and let you know what we may find.
Thanks,
Nathan