- Mon May 16, 2011 2:49 am
#127264
Hey Everyone,
Quick question really, I can send AT commands to the Telit 862GPS via Python no problems. I'm just starting out though and I want to code it robustly. I can't find a good example online, here's my attempt:
Cheers, Dave.
Quick question really, I can send AT commands to the Telit 862GPS via Python no problems. I'm just starting out though and I want to code it robustly. I can't find a good example online, here's my attempt:
Code: Select all
What do you think?# Setup Booleans!
True, False = 1, 0
def at_command(command, win="OK", fail="ERROR", delay=10):
# Send the command
MDM.send(command + '\r', 5)
# Wait for the response
for i in range(delay):
# Listen to serial port for click
res = MDM.receive(1)
# See what happened
if res.find(win) > -1:
return False, res
if res.find(fail) > -1:
return True, res
# Timed out :(
return True, "Timed out"
Cheers, Dave.