# How to read IO status from XBEE to connectport X$

**URL:** <https://forums.digi.com/t/how-to-read-io-status-from-xbee-to-connectport-x/13224>\
**Category:** Python\
**Tags:** connectport-x4, python, xbee\
**Created:** [June 27, 2014, 3:09pm UTC](https://forums.digi.com/t/how-to-read-io-status-from-xbee-to-connectport-x/13224 "2014-06-27T15:09:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Electrofab](https://avatars.discourse-cdn.com/v4/letter/e/c67d28/32.png) [@Electrofab](https://forums.digi.com/u/Electrofab)\
**Post date:** [June 27, 2014, 3:09pm UTC](https://forums.digi.com/t/how-to-read-io-status-from-xbee-to-connectport-x/13224/1 "2014-06-27T15:09:46Z")

</div>

I have a CPx4 and a xbee rf module.  
I am wanting to read the IO status from the remote module back to the CPx4.  
What i think i need to do is send it to the comport of the CPx4 but i cant get my python code to work.

any help would be great!

---

<div class="post-metadata">

**Author:** ![mvut](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.digi.com/mvut/32/31_2.png) [@mvut](https://forums.digi.com/u/mvut)\
**Post date:** [June 27, 2014, 4:01pm UTC](https://forums.digi.com/t/how-to-read-io-status-from-xbee-to-connectport-x/13224/2 "2014-06-27T16:01:22Z")

</div>

No, you do not use the COM port on the gateway to collect this data . Instead you use a sd.receive or something of that nature. Try using the Hello world example for your specific XBee version and it will provide you with the proper command to access the radios data.

---

<div class="post-metadata">

**Author:** ![Electrofab](https://avatars.discourse-cdn.com/v4/letter/e/c67d28/32.png) [@Electrofab](https://forums.digi.com/u/Electrofab)\
**Post date:** [June 27, 2014, 4:13pm UTC](https://forums.digi.com/t/how-to-read-io-status-from-xbee-to-connectport-x/13224/3 "2014-06-27T16:13:04Z")

</div>

The x4 is  
X4-HMU-U801-A  
the xbee module is  
XBP9B-DMSTB002  
I have done the hello word and it dose not tell me anything about any command other than print (’ ')

could you give me an example?

---

<div class="post-metadata">

**Author:** ![mvut](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.digi.com/mvut/32/31_2.png) [@mvut](https://forums.digi.com/u/mvut)\
**Post date:** [June 27, 2014, 4:20pm UTC](https://forums.digi.com/t/how-to-read-io-status-from-xbee-to-connectport-x/13224/4 "2014-06-27T16:20:08Z")

</div>

Try this one:

import sys, os  
from socket import \*

# The Format of the tuple is:

# (address\_string, endpoint, profile\_id, cluster\_id)

# 

# The values for the endpoint, profile\_id, and

# cluster\_id given below are the values used to write

# to the serial port on an Ember-based XBee module.

DESTINATION=(“00:0d:6f:00:00:06:89:29!”, 0xe8, 0xc105, 0x11)

# Create the socket, datagram mode, proprietary transport:

sd = socket(AF\_ZIGBEE, SOCK\_DGRAM, ZBS\_PROT\_TRANSPORT)

# Bind to endpoint 0xe8 (232):

sd.bind((“”, 0xe8, 0, 0))

# Send “Hello, World!” to the destination node, endpoint,

# using the profile\_id and cluster\_id specified in

# DESTINATION:

sd.sendto(“Hello, World!”, 0, DESTINATION)

---

<div class="post-metadata">

**Author:** ![Electrofab](https://avatars.discourse-cdn.com/v4/letter/e/c67d28/32.png) [@Electrofab](https://forums.digi.com/u/Electrofab)\
**Post date:** [July 1, 2014, 11:25pm UTC](https://forums.digi.com/t/how-to-read-io-status-from-xbee-to-connectport-x/13224/5 "2014-07-01T23:25:25Z")

</div>

How do i read/ use the data coming into the x4? I have tried listening but I dont know what port the xbee module in the x4 it is attached to.

---

<div class="post-metadata">

**Author:** ![mvut](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.digi.com/mvut/32/31_2.png) [@mvut](https://forums.digi.com/u/mvut)\
**Post date:** [July 2, 2014, 11:27am UTC](https://forums.digi.com/t/how-to-read-io-status-from-xbee-to-connectport-x/13224/6 "2014-07-02T11:27:50Z")

</div>

You do not need to worry about that. All you need to do is to create the socket as described above and then use the sd.read function to read the data coming in.

---

<div class="post-metadata">

**Author:** ![16ksa23](https://avatars.discourse-cdn.com/v4/letter/1/aeb1de/32.png) [@16ksa23](https://forums.digi.com/u/16ksa23)\
**Post date:** [July 25, 2014, 1:10am UTC](https://forums.digi.com/t/how-to-read-io-status-from-xbee-to-connectport-x/13224/7 "2014-07-25T01:10:26Z")

</div>

In the given program, replace the sendto function with read function.  
sd.read() or sd.recvfrom(buflen).  
Refer following link for the syntax, [http://www.digi.com/wiki/developer/index.php/XBee\_Extensions\_to\_the\_Python\_socket\_API#recvfrom.28.29](http://www.digi.com/wiki/developer/index.php/XBee_Extensions_to_the_Python_socket_API#recvfrom.28.29)
