3 import sys, os, string, socket, time
4 from popen2 import popen2
5 from pyPgSQL import PgSQL
6 from LATClient import LATClient
8 asynchronous_responses = [ '400', '401', # door open/closed
9 '610', # switches changed
13 def __init__(self, rfh, wfh):
19 def await_prompt(self):
25 if s == '': raise Exception
26 if s == '\n' and state == 0: state = 1
27 if (s == '#' or s == '%') and state == 1: state = 2
28 if s == ' ' and state == 2: state = 3
30 def get_response(self):
34 s = self.rfh.readline()
35 if s == '': return None
37 return (s[0:3], s[4:])
40 self.wfh.write('PING\n')
41 (code, string) = self.get_response()
45 if __name__ == '__main__':
46 # Open vending machine via LAT
47 latclient = LATClient(service = 'VEND', password = 'dmscptd')
48 (rfh, wfh) = latclient.get_fh()
49 v = VendingMachine(rfh, wfh)