Accessing MAC Address, Firmware version etc.. from within Python

I’ve got an X2 and I want my python code to gather some information when it boots and send it to my remote server.

Is there a good way to access:

MAC Address
Firmware Version of the Connectport (Boot and Post)
XBEE Extended Address for the Connectport
PAN ID
IP address/submask/gateway
DHCP setting

I’d prefer not to go to os.system or subprocess to get this info from the command line tools.

thanks!

Hi mli,

Yes there is a easy way to gather that information. The module you’re looking for is called ‘digicli’, which is basically access to the command line interface via python. You can read more about it here: http://www.digi.com/wiki/developer/index.php/Digicli

The typical usage for gather information is doing the following:

Define what information you want
Find the CLI command that will display that information
Create a regular expression to distill the information
Call digicli with the command, parsing the results with regular expression.

On a sidenote, currently on Digi’s NDS products, os.system and the subprocess module are not supported, so this the only means to execute command line arguments to the device currently. An alternative to this is to use the RCI facilities in the device, which is basically XML formatted command and responses. This is typically more complicated than what a user needs, but if you want to be cross platform on Digi’s devices, the way to do it.

Hope this answers your question,
Max

Thanks for the response. It works well for my purposes and doesn’t seem to add much to the memory usage of my Dia device driver.

Along those same lines I would like to add a page to the x2 setup website.

I would like it to launch a python script on the x2 to handle configuration information.

I figured out how to add a page, but not how to launch the cgi like script.

Any ideas?

If you have the X2 with plastic case (so 8MB RAM), then be warned that it has limited memory - so be cautious and do things in small chucks.

You cannot run CGI directly on the X, however there is a ‘catch-all’ method which passes all unknown URI to Python, which allows you to create a ‘text string’ response which the X2 returns as the HTTP response. See this page: http://www.digi.com/wiki/developer/index.php/Module:digiweb

Note that your callback script cannot exit, so you cannot ‘load’ a callback in a stand-alone script. The tool managing your CGI needs to remaining running for the callback to function.