I have a python script that I want to use to configure some XBee modules. It works perfectly find when connect to a computer via an xbee development board, but fails when connect to a raspberry pi via the slice of pi board.
I have narrowed down the problem to it failing to enter the command mode, after sending the +++ the xbee never sends the OK message. Here is the relevant code:
...
CC = '+'
GT = '1.1' # Tried different values here
...
def startCommandMode(self):
self.emptyBuffer() # Tried with and without this line
sleep(self.GT) # Tried with and without this line
self.ser.write(self.CC + self.CC + self.CC)
sleep(self.GT)
return self.getReply() == 'OK'
...
def getReply(self):
count = 0
reply = ''
while True:
char = self.ser.read()
if char == '\r':
break
if len(char) == 0:
return None
reply += char
return reply
The full source is available on github if needed.
I know it is not a problem with the xbee module, the raspberry pi or the slice of pi board as it works perfectly fine if I try it manually using "picocom -lc /dev/ttyAMA0".
sleep()is really sleeping for 1.1 seconds? - tomlogic