Home/Support/Support Forum/Python xbee device.read_data doesn't read pushed remote data
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Python xbee device.read_data doesn't read pushed remote data

+1 vote
I have set up several XBee S3Cs to sample analog pins 1 and 2 every 15 seconds with the destination address of another S3C set up as coordinator. I can see the frames--IO Data Sample RX Indicators--in XCTU and there is a value for the pins (1023 since nothing is attached to them yet). When I try to read the frame in a Python script (below), it never seems to get the data.

I believe the correct port is being opened because the program gives an error is XCTU is still connected and XCTU won't connect if the program is running.

CE = Standard Router [0]
CI = 11
AP = API Mode without escapes [1] (but I've tried 2 as well)
AO = API Rx Indicator - 0x90 [0] (but I've tried 1 as well)

Any thoughts?

# Copyright 2017, Digi International Inc.
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

from digi.xbee.devices import XBeeDevice

# TODO: Replace with the serial port where your local module is connected to.
PORT = "COM4"
# TODO: Replace with the baud rate of your local module.
BAUD_RATE = 9600


def main():
print(" +
+")
print(" | XBee Python Library Receive Data Polling Sample |")
print(" +
+\n")

device = XBeeDevice(PORT, BAUD_RATE)

try:
device.open()

device.flush_queues()

print("Waiting for data...\n")

while True:
xbee_message = device.read_data()
# xbee_message = device.read_expl_data()
if xbee_message is not None:
print("From %s >> %s" % (xbee_message.remote_device,
xbee_message.data()))


finally:
if device is not None and device.is_open():
device.close()
asked Mar 5, 2019 in Python by robinmcc54 New to the Community (1 point)

Please log in or register to answer this question.

...