简体   繁体   English

Raspberry Pi Xbee串行。串行超时无法使用Python

[英]Raspberry Pi Xbee serial.Serial timeout not working Python

I am trying to connect Rasberry Pi with Xbee on UART header ttyAMA0 我正在尝试将Rasberry Pi与UART头ttyAMA0上的Xbee连接

Both are connected and I am getting response of +++ -> OK 两者都已连接,并且我正在获得+++的响应->确定

Xbee is on mode 2 API Xbee使用模式2 API

s = serial.Serial("/dev/ttyAMA0", 9600, timeout=5)
xb = ZigBee(s)
xb.send('at', command="SH")
print "working till now"
ansh = xb.wait_read_frame()
print "don't wait here there is a time out"

I am getting output 我正在输出

working till now 工作到现在

And code goes for infinite wait 代码需要无限等待

Please help 请帮忙

I also had this problem with the "SH" at command. 我在命令中也遇到了“ SH”这个问题。 After a LOT of debugging and pretty much taking apart the Python-Xbee library I eventually found the solution! 经过大量的调试并几乎分解了Python-Xbee库之后,我终于找到了解决方案! Add "escaped=True" to the constructor: 向构造函数添加“ escaped = True”:

xb = Zigbee(s, escaped=True) xb = Zigbee(s,逃脱= True)

It would seem that the SH (High Address) response contains bytes which need escaping. 似乎SH(高地址)响应包含需要转义的字节。 Also check your API mode matches. 还要检查您的API模式匹配情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM