- self.await_prompt()
- return (code, text)
-
- def handle_event(self, code, text):
- pass
-
- def authed_message(self, message):
- if self.challenge == None:
- return message
- crc = do_crc('%c%c'%(self.challenge >> 8, self.challenge & 0xff))
- crc = do_crc(self.secret, crc)
- crc = do_crc(message, crc)
- return message+'|'+('%04x'%crc)
-
- def ping(self):
- self.wfh.write('PING\n')
- (code, string) = self.get_response()
- return (code == '000', code, string)
-
- def vend(self, item):
- if not re.search('^[0-9][0-9]$', item):
- return (False, 'Invalid item requested (%s)'%item)
- self.wfh.write(self.authed_message(('V%s\n'%item)+'\n'))
- (code, string) = self.get_response()
- return (code, string)
-
- def beep(self, duration = None, synchronous = True):
- msg = 'B'
- if synchronous: msg += 'S'
- if duration != None:
- if duration > 255: duration = 255
- if duration < 1: duration = 1
- msg += '%02x'%duration
- self.wfh.write(msg+'\n')
- (code, string) = self.get_response()
- return (code == '500', code, string)
-
- def silence(self, duration = None, synchronous = True):
- msg = 'C'
- if synchronous: msg += 'S'
- if duration != None:
- if duration > 255: duration = 255
- if duration < 1: duration = 1
- msg += '%02x'%duration
- self.wfh.write(msg+'\n')
- (code, string) = self.get_response()
- # FIXME: workaround a bug in rom W. should be just: return (code == '500', code, string)
- return (code == '500' or code == '501', code, string)