2011-07-13 22:02:03 +00:00
|
|
|
#!/opt/local/bin/python
|
|
|
|
|
|
|
|
import sys,serial
|
|
|
|
|
|
|
|
def read_until(token):
|
|
|
|
while 1:
|
|
|
|
line = ser.readline(None,"\r")
|
|
|
|
sys.stdout.write(line)
|
|
|
|
|
2011-07-13 22:28:34 +00:00
|
|
|
if (line.startswith(token)):
|
2011-07-13 22:02:03 +00:00
|
|
|
break
|
|
|
|
return line
|
|
|
|
|
|
|
|
|
2011-07-13 23:01:45 +00:00
|
|
|
ser = serial.Serial(sys.argv[1], 57600, timeout=5, dsrdtr=False, rtscts=False)
|
|
|
|
|
|
|
|
read_until("+READY")
|
2011-07-14 02:13:57 +00:00
|
|
|
ser.write(sys.argv[2])
|
2011-07-13 23:01:45 +00:00
|
|
|
|
2011-07-13 22:02:03 +00:00
|
|
|
line = read_until("+OK")
|
2011-07-13 23:01:45 +00:00
|
|
|
ser.close()
|
2011-07-13 22:02:03 +00:00
|
|
|
if (line.find("PASS") != -1):
|
|
|
|
sys.exit(0)
|
|
|
|
else:
|
|
|
|
sys.exit(1)
|