Example #1
0
 def wait_response (self):
   link = self.link
   for buf in link.dump_rx_buffer( ):
     resp = Packet.fromBuffer(buf)
     if self.responds_to(resp):
       print "READ"
       print lib.hexdump(buf)
       return resp
Example #2
0
 def __init__ (self, com, state):
   # print com, com.__name__
   self.name = com.__name__.split('.').pop( )
   #print com
   self.com = com
   self.code = com.code
   self.state = state
   self.resp = Packet.fromCommand(com, serial=state.serial, crc=0x00)
Example #3
0
 def ack (self):
   null = bytearray([0x00])
   pkt = Packet.fromCommand(self.command, payload=null, serial=self.command.serial)
   pkt = pkt._replace(payload=null, op=0x06)
   buf = pkt.assemble( )
   print "ACK tx", str(buf).encode('hex')
   encoded =  FourBySix.encode(buf)
   self.link.write(encoded)
   self.link.triggerTX( )
Example #4
0
 def wait_for_ack (self):
   link = self.link
   # while not self.done( ):
   for buf in link.dump_rx_buffer( ):
     print "wait_for_ack"
     resp = Packet.fromBuffer(buf)
     if self.responds_to(resp):
       print lib.hexdump(buf)
       if resp.op == 0x06:
         # self.unframe(resp)
         print "found valid ACK"
         return resp
Example #5
0
 def prelude (self, command):
   link = self.link
   self.expected = command.bytesPerRecord * command.maxRecords
   self.command = command
   # payload = bytearray([len(command.params)]) + bytearray(command.params)
   payload = bytearray([0])
   self.pkt = Packet.fromCommand(command, payload=payload, serial=command.serial)
   self.pkt = self.pkt.update(payload)
   buf = self.pkt.assemble( )
   print "sending", str(buf).encode('hex')
   encoded =  FourBySix.encode(buf)
   self.send(encoded)
   print "searching response for ", command, 'done? ', self.done( )
Example #6
0
 def send_params (self):
   command = self.command
   params = self.command.params
   payload = bytearray([len(params)]) + bytearray(params)
   missing = [ ]
   missing = bytearray([0x00]) * (64 - len(params))
   payload = payload + missing
   pkt = Packet.fromCommand(command, payload=payload, serial=command.serial)
   pkt = pkt.update(payload)
   buf = pkt.assemble( )
   print "sending PARAMS", str(buf).encode('hex')
   encoded =  FourBySix.encode(buf)
   self.link.write(encoded)
   self.link.triggerTX( )
   # self.link.write(encoded)
   # self.link.triggerTX( )
   self.sent_params = True