DIO change status not received in python

hi ,
i have 2 xbee S1 linked , send receive is ok via xctu and my python program .the only issue is my push button (connected to one of the xbees set in DIOo) when pressed i get the api frame (change detect) via xctu but not in my python program , althought it’s a loop listening for all incoming data (i have tried a basic python serial listen port is ok and also all kind of terminals are receiving the data)

XBee setup

    self.serial_port = "COM10"  
    self.xbee_device = XBeeDevice(self.serial_port, 1200)
def start_xbee(self):
    try:
        self.xbee_device.open()


        print("Device serial port opened successfully.")
        print("Waiting for data...")

        while True:

            xbee_message = self.xbee_device.read_data()

It does not look like you are looking for Hex data packets.

xbee_device.read_data() suppose to receive any kind of data (it works with sending manually frame from xctu) the only data i don’t receive is when change detect of the remote xbee occurs (even i see the same data from other apps (xctu, terminal, and even pyserial))
the pb is for sure the way the library xbee_device.read_data() works (maybe flow control) i dont know really i’m stuck

What library are you using?

Do you have AP set on the radio for 1 or 2?

import digi.xbee.devices
all api is set and works (checkked with xctu)

Tewfik,

What Library are you using to obtain the function “xbee_device.read_data()”? Where did you obtain it from?

digi-xbee version 1.4.1
i use pycharm with python 3.12 and my pyserial 3.5
all updated

https://xbplib.readthedocs.io/en/latest/user_doc/communicating_with_xbee_devices.html?highlight=read_data()#polling-for-data
I don’t know if you are already doing this, but you need to have the read_data in a loop as the DIO data will be sent as an Asynchronous function.

yes i do
# XBee setup
self.serial_port = “COM10” # Replace with your port
self.xbee_device = XBeeDevice(self.serial_port, 1200)
def start_xbee(self):
try:
self.xbee_device.open()

        print("Device serial port opened successfully.")
        print("Waiting for data...")

        while True:

            xbee_message = self.xbee_device.read_data()


            if xbee_message:


                    deviceid = str(xbee_message.remote_device.get_64bit_addr())

                    rssi_bytearray = xbee_message.remote_device.get_parameter("DB")
                    rssi = int.from_bytes(rssi_bytearray, byteorder='big')  # Convert bytearray to int

                    print(f'Message from ID: {deviceid}, RSSI: {rssi}')
      time.sleep(0.1)
    except Exception as e:
        print("Error:", e)

Is there a specific reason you are trying to run at a 1200 baud rate and not something like 9600 or 115.2kbps?

No I was running basically with 57600 then I tried many rates (including 9600) to see if reducing baud rate will fix that
Anyway the com is working fine since with the same code I receive api if I send it manually with xctu only dio change detect api ( tx 83) is not working while this same api is received if I use terminal or serial read ()