xbee.wait_read_frame() and X-CTU problems

695 views
Skip to first unread message

Kempis

unread,
Sep 12, 2013, 5:01:29 PM9/12/13
to pytho...@googlegroups.com
Hello
I've a big problem with  xbee.wait_read_frame().
I'm using 2 Xbee  XB24-ZB S2 in Api mode (1 router and 1 coordinator). ATAP 2, ATD6 and ATD7=0.
The coordinator is connected with raspberry pi (I'm using the serial port of the GPIO 'ttyAMA0', but i've tried also 'ttyUSB0') the other is connected on the arduino board (without  Atmega 328).
On the arduino side i'm using the X-CTU program in order to see the streaming of data.
If i send the data from raspberry py i'm able to view the data directly on the X-CTU terminal without problems.
If i try to use the assembly packet for send the data from X-CTU to raspberry pi (with the enclosure program) nothing appear, the raspberry doesn't receive data
I've used all the frame sistem (for the checksum i use Digi Api Frame)
Where are my mistakes ?
Somebody can help me in order find the right data format for to send the value from X-CTU to Raspberry via Xbee ??

Thanks

#! /usr/bin/python
"""
receive_samples.py
By Paul Malmsten, 2010

This example continuously reads the serial port and processes IO data
received from a remote XBee.
"""
from xbee import XBee, ZigBee
import serial
#PORT = '/dev/ttyUSB0'
#BAUD_RATE = 9600
PORT = '/dev/ttyAMA0'
BAUD_RATE = 9600

# Open serial port
ser = serial.Serial(PORT, BAUD_RATE)

# Create API object
#xbee = XBee(ser)
#xbee = ZigBee(ser,escaped=True)
xbee = ZigBee(ser)


# Continuously read and print packets
while True:
    try:
        response = xbee.wait_read_frame()
        print response
    except KeyboardInterrupt:
        break
       
ser.close()

Paul Malmsten

unread,
Sep 15, 2013, 1:43:29 PM9/15/13
to pytho...@googlegroups.com
Hi Kempis,

I assume the XBee ZB connected to your PC with X-CTU is in API mode (API=1). When you use 'Assemble Packet', the data you enter must follow the format specified in Chapter 9 of the XBee ZB product manual (http://ftp1.digi.com/support/documentation/90000976_P.pdf), beginning at page 98. If your packet does not follow this format exactly using the checksum described there, it is likely that your PC-attached XBee will ignore the message you attempt to send.

Here are a few other things you can check:
  • The Raspberry-Pi XBee must be in API mode (API=1); the code you posted does not have escaping on by default.
  • The Raspberry-Pi XBee must also be configured to use 9600 baud for a data rate.
~Paul Malmsten


--
You received this message because you are subscribed to the Google Groups "Python XBee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-xbee...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Kempis

unread,
Sep 15, 2013, 5:01:21 PM9/15/13
to pytho...@googlegroups.com

Thanks Paul!!
It's working now!!
Both Xbee are now on API=1 , 9600 Baund.
I've used the Digi API Frame Maker with Frame type 0x10 Transmit Request.
If i use the API=1 i don't need to consider the escape characters
In any case on the code that i've posted, the row with xbee=Zigbee(ser)  work also with option escape=true.

Thanks again

Kempis from Italy

Prasanna Mhapsekar

unread,
Oct 3, 2017, 4:19:43 AM10/3/17
to Python XBee
Even i have had my share of problems with xbee.wait_read_frame(). In my case, it doesnt work the same each time, it seems to work sometimes as a burst of proper responses and some other time wait_read_frame() gets blocked. Im sending a payload 'yolo' through transmit request frames through XCTU frame generator and console. My code is as below... (the print statements are for troubleshooting)
 
#!/usr/bin/python
from serial import Serial
import time
from xbee import ZigBee

#Starting serial connection
serialPort = Serial('/dev/ttyAMA0',9600,timeout=0.5)
xbee = ZigBee(serialPort)

while 1:
  print "loop"
  try:
    print "try"
    data= xbee.wait_read_frame()
    print "data"
    id= data
    print(id)
    print "exit loop"
  except KeyboardInterrupt:
    break

serialPort.close()

the output is attached as a screenshot to showcase that it really works at times, at other times it gets blocked. please do help me out...

thanx! :)
Screenshot from 2017-10-03 13-44-16.png
Reply all
Reply to author
Forward
0 new messages