Xbee to connectport transfer

I am trying to transfer data from my Xbee series 2 module to a connectport X4. Which is the best method of dataa transfer ie UDP, TCP/IP etc ?? Also how do you determine which method to use for what ? Also are the codes in Samples folder sufficient ?

Hi, To do data transfer between other xbee zb module and ConnectPort X4 gateway, you need to bind them. You can go through the code given the following wiki link:


Traceback (most recent call last):
File “WEB/python/tcp_zig_dynamic_mapping.py”, line 122, in ?
listen_sock.bind((“”, tcp_port))
File “”, line 1, in bind
socket.error: (112, ‘Address already in use’)

Is the error it gives when i run the code. But before giving this error it is able to detect the Zbee module

If you didn’t change ‘tcp_port’ away from the default of 20000, then you are running the code a second after it failed the first time.

Only 1 task can bind on a port, and if your code doesn’t gracefully close that port before crashing, then you need to reboot the X4 to recover it.

The X4 is not like a PC, so when a task dies, the X4 cannot understand what resources to free up. Thus if you application ides, crashes or is ended, the TCP port 20000 may be left locked & in use by nothing.

Thanks Lynn. That problem was solved with your help. Now, while entering the loop it displays “Entering Main loop” and then runs an infinite loop without displaying anything or breaking out. Is there something wrong or am I on the right path ?

Perhaps - I haven’t run this particular script, but select.select() (as coded here) will block forever waiting for incoming traffic.

Youc ould add a print under the ‘if listen_sock in rl’, which would show you when something connects. So if you run 'telnet {ip} 20000" on a PC, you should see the listen_sock triggered. At this point, I think anything your XBee send should show up at the PC’s telnet session. Per this design, you will see the ‘node_1:{data}’, using the name you put into table.py file.

In the main while loop i put print statements under each of the if conditions. Still there is no output. This means that none of the conditions are getting satisfied. How do i proceed ?

I had another doubt in this code. The end point, cluster id and profile id - how are they determined ? Because the ones i am using are the standard ones on the code, I havent changed anything

Look at http://www.wireshark.org/

I assume you are NOT connecting via Ethernet, thus nothing else has any function. Wireshark will allow you to see if you are getting close or not. You can add a timeout to the select (look up the function on line). I often set a 1 or 2 minutes timeout so I can ‘see’ somethign happen when there is no network traffic.

cluster/profile/end-point would all be default unless you changed them in the modules.