python - Not getting a response from wait_read_frame() -
I can not get Python-XB library to get feedback from my remote router. Local Xbee is a coordinator API, they are connected, the remote is a router AT.
This is not a connection problem because I can use XCTU to send and receive remote packets without any problem. I am using Series 2 xbs.
I added a class to help parse serial responses. It prints fine for local 'A' orders, but all 'remote_at' commands are suspended; no response has been printed. I can issue a remote_it command (without waiting for the response) and it has been processed properly by remote XBI Removing the remote command hanging on wait_read_frame (). I have tried to wait a few minutes, but it is stuck now.
I can copy the D1 input pin and return its position (High \ x05
, Low \ x04
or \ x00
)
Here is the code that I am using to debug. I wrong? Serial import serial port = '/ dev / ttyAMA0' myRouter = 'a big long hex string ...' xbee import xbeee import-time at DEF message_received (what data I'm doing) : Print data class TappedSerial (serial): def __init __ (self, * args, ** kwargs): Super (TappedSerial, self) .__ init __ (* args, ** kwargs) def (read self, * args, * * Kwargs): data = super (serial, self). READ (* ELGS, ** QUARGE) PRINT ("READ:", REPR (data)) Return data DRF (self, data, ** quad): print ("Written:", wrapper (data)) Super (Serial, self) .write (data, ** kwargs) DEF main (): try tapped_ser = TappedSerial (port = port, baudrate = 9600) xbee = XBee (tapped_ser) #, callback = message_received): xbee.remote_at ( Dest_addr_long = myRouter, command = 'D1', option = '\ x00') response = xbee.wait_read_frame () print (feedback) except the KeyboardInterrupt: Passed in the end: tapped_ser.close () Print ("Program Exit") if__name__ == '__main__': main ()
Two things have given me In the installation of the library:
-
In the version that I have checked in base.py, in line 74, callback was set, the code to start the background thread Has been commented on. Since you have read the requests, I do not think this is your problem, but anyone else gets it with similar problem. You can call xbee.start (To create thread run manually)
-
I found that in this case enabling Python logging was a bit more useful than tappedSerial -. I add logging to the top on the following:
logger = logging.getLogger () logger.setLevel (logging.DEBUG) ch = logging.StreamHandler () ch.setLevel (logging.DEBUG) logger. Adhendler (CH)
It says that I was adding 4 bytes to my ND responses because I had a number of 3 instead of 3 I did not. I will request a bridge that connects the parameters DD value if it is defined, as determined by the closure by 4.
Comments
Post a Comment