Python: xbee.receive() and xbee.wait_read_frame() don't work

Hello,

I have one XBee S2C (Coordinator) and try either to receive data from another Xbee S2C (Router)or to read the data sent by the coordinator. The xbee.receive() and the xbee.wait_read_frame()respectively do not give any feedback in the Python codes:

Program 1:
#! /usr/bin/python

Import and init an XBee device

from xbee import XBee, ZigBee
import serial

ser = serial.Serial(‘COM4’, 9600)
xbee = XBee(ser)

while True:
try:
print (“Daniel Berger”)
response = xbee.wait_read_frame()
print response
except KeyboardInterrupt:
break

ser.close()

Program 2:
import XBee
from time import sleep

if name == “main”:
xbee = XBee.XBee(“COM4”) # Your serial port name here

# A simple string message
sent = xbee.SendStr("Hello World")
sleep(0.25)
Msg = xbee.Receive()
if Msg:
    content = Msg[7:-1].decode('ascii')
    print("Msg: " + content)

# A message that requires escaping
xbee.Send(bytearray.fromhex("7e 7d 11 13 5b 01 01 01 01 01 01 01"))
sleep(0.25)
Msg = xbee.Receive()
if Msg:
    content = Msg[7:-1]
    print("Msg: " + xbee.format(content))

It is working with XCTU.
I would be happy to get feedback
Regards and thank you very much
Daniel

What are these examples running on and where did you get them from?

Hello,
I have found the code at
https://pypi.python.org/pypi/XBee (Program 1, code: receive_samples.py)
https://github.com/nicolerey/Thesis (Program 2)
I work with Windows 10 on a laptop

I have done some additional experiments as I’m new to Python and XBee and I have got some data, but there are in a ‘strange’ format:

import serial
import time
from xbee import ZigBee
serial_port = serial.Serial(‘COM4’, 9600)

def print_data(data):
print data

zigbee = ZigBee (serial_port, callback=print_data)
print zigbee
while True:
print zigbee
test = serial_port.read()
print (“data”)
test2 = zigbee.api_responses.values()
test3 = zigbee.api_responses.items()
# test4 = zigbee.wait_read_frame()
# print (test.decode(‘ascii’))
print test
print test2
print test3
# print test4
print ‘.’
try:
time.sleep(0.001)
test4 = zigbee.wait_read_frame()
except KeyboardInterrupt:
break

zigbee.halt()
serial_port.close()

Therefore I would like to know where to find a documentation (examples and descriptions) and how can I get the right format of the xbee data. Is an S2C-device Xbee or Zigbee in the Python-code? I’m not fully sure about the correct code.
Regards and thank you very much
bergiel