I/O periodic sampling (Frame structure) CP-X2

hi; i wrote a script on CP-X2 to bind a TCP socket to an endpoint socket (non-blocking) to read the periodic samples of ADC 1,
1- i succeeded to receive the frame but it is not a complete API frame an example :010000020237 this is a correct one but why i can not receive the complete API frame 7E…Checksum
is this a normal behaviour?
2- i noticed to that when i send remote API frame like commands i do not receive a response at all
3- is this related to AO command on the coordinator ?
4- i tried to understand the differenece between transparent and explicit Rx indicator but could not ? can you please help ?

Do I understand you correctly that you are using Python to speak to the XBee network since you said you used the bind() function?

Jordan

yes i am using python on connectport X2,
two issues arise here:
1- sampled I/O frames are striped without the 7E…checksum structure.
2-when i send a Remote Command -the attached image shows the frame structure of the sent command-
the API identifier is 0x11 (explicit addressing command frame) and my command is being appended as “Data”.

i tried to refer to the python programming guide to understand why it is behaving like this…but was not lucky enough.
i tried to to refer to the module Doc to understand the difference between explicit addressing , Explicit Rx indicator …but was not lucky enough either.

Message was edited by: hyasin@advantech.com.sa

Message was edited by: hyasin@advantech.com.sa

SOS SOS SOS…

When you use the ConnectPort X2 gateway, you do not communicate with the radio using the API packets. Instead some new abstractions have been provided for you. If you want to send remote commands you use the zigbee module and the ddo_* functions. For example, to set the node name remotely to a node with the extended address 00:11:22:33:44:55:66:77!:

import zigbee
zigbee.ddo_set_param(‘00:11:22:33:44:55:66:77!’, ‘NI’, ‘NODE-NAME’)

Data is handled through the sockets API. Are you using an 802.15.4 or ZNet 2.5 radio?

In order to send a message “hello world” out the serial port of another node using an 802.15.4 radio:

import socket
sd = socket.socket(socket.AF_ZIGBEE, socket.SOCK_DGRAM, socket.ZBS_PROT_802154)
sd.bind((‘’, 0, 0, 0))
sd.sendto(‘Hello, world!’, 0, (‘00:11:22:33:44:55:66:77!’, 0, 0xc105, 0x11))

Data is received using the recvfrom() method of a bound socket object:

buf, addr = sd.recvfrom(128)

If you setup a node to periodically transmit I/O samples to you will receive these samples using the above recvfrom() method. I/O samples may be multiplexed with other types of data (e.g. messages from serial ports, network messages, etc.) In order to differentiate them you will need to look at the fourth field of the addr structure you receive with the data:

buf, addr = sd.recvfrom(256)
if addr[3] == 0x92:

insert your method here to parse the I/O sample

Tell me more about your application. Have you built custom hardware that you are using with the remote XBee modules? I have an example of Python code which details how to configure and monitor the Digi XBee Analog I/O adapters. I would be happy to post it here.

Jordan

thank you for your reply;
i use Znet based modules, i tried to minimise the parsing and handling of frames on the CP-X2 and let my software handle the frames , parsing commands ,…
i built the hardware using the Znet 2.5 API firmware, it is a temperature sensor (Analog) and a door sensor (Digital).
please upload the python script example, you shall save me from a big trouble since i started feeling helpless :slight_smile:

Let us start with doing change detection on a single door sensor. This should be illustrative of quite a few of the programming and systems principles of working with the CP X2 environment.

Please find attached two files: int_sampling.py and xis.py

Please upload both files to your ConnectPort X2 device and then open a copy of int_sampling.py in your favorite source code editor.

You can see that int_sampling.py takes two arguments: a common-separated 64-bit address of a single XBee device as well as a timeout value.

You may run it by telnetting to the ConnectPort X2 device and typing the following at the prompt:

#> python int_sampling.py 00:11:22:33:44:55:66:77! 10.0

The script will initialize the remote command registers (called DDO values) assert pull-ups on DIO0, DIO1, DIO2, and DIO3 and monitor these pins for changes.

The script is intended to work with an XBee development board so you may wish to use it before you try to use it with your door sensor.

After the, “application ready,” message is printed you may see the loop which starts with a call to select(). The select() method is a special call which allows a set of socket descriptors–handles to XBee endpoints, serial descriptors, or TCP/IP network endpoints–to be monitored for new data or exceptions.

When select() returns a check is performed to see if there is new data from the XBee endpoint. If so, it is checked to see if it is an I/O sample. If it is an I/O sample it is parsed and the information is printed to the console.

This application could easily be modified to send the contents of the API frame to a PC via TCP/IP if you’d wish to parse it there.

I hope this is a good start for you!

Jordan

Thank you very much for the time and effort it took you to clarify things for me.
i noticed that you set the address to transmit to is the address of the coordinator in the CP-X2


Get the ConnectPort radio’s address:

src_addr_high = zigbee.ddo_get_param(None, ‘SH’)
src_addr_low = zigbee.ddo_get_param(None, ‘SL’)

Set the remote radio transmit destination to our

radio’s address:

zigbee.ddo_set_param(dest_addr, ‘DH’, src_addr_high)
zigbee.ddo_set_param(dest_addr, ‘DL’, src_addr_low)


1- does this mean i can force a certain radio to communicate with any radio directly without the need to join the PAN ?

2- what about quiried sampling : can i do it using the ddo ?

Hello Hani,

In response to 1, above: setting the DH and DL registers of a remote node to match the address registers SH and SL sets up unicast transmission for that remote node. Both nodes need to be joined to the PAN in order to communicate with one another first. If they were not joined to the PAN, this DDO command would fail.

In response to 2, above: you can perform a sample query very easily:

sample = zigbee.ddo_get_param(dest_addr, ‘IS’)

You then parse the returned sample just as you would any other sample frame.

I hope this helps!

Jordan

perfect as perfect, thank you very much , i can now understand the python APIs better.
I wish the Python programmers guide be rewritten, i hope when i finish this project i shall help in providing a summed up tutorial.
we also look forward the release of the enabled relaport firmware since it shall provide a more flexible way to communicate with the CP-X2 radio esp for non-python developers.

The firmware you speak of (82001631) is still being developed/tested by our engineering staff and will be released shortly.

I don’t have a date to give on when you can expect it, all I can say is in the near future (hopefully by the end of August).