Exemplo n.º 1
0
 def parse_data(self, d):
     # Translate to higher level function
     if d["type"] == "controlRead" and d["bRequest"] == 0x02:
         indented("vendor_request1()")
     # Ignore bulk reads
     elif d["type"] == "bulkRead":
         pass
     # Default: print as normal python replay
     else:
         self.pyprint.parse_data(d)
Exemplo n.º 2
0
 def next_json(self, j, prefix=None):
     if j['type'] == 'read':
         interface = j['interface']
         data = binascii.unhexlify(j["data"])
         indented("buff = ser%u.read(%u)" % (interface, len(data)))
         indented("validate_read(%s, buff, \"%s\")" %
                  (bytes2AnonArray(data), "packet"))
     elif j['type'] == 'write':
         data_str = bytes2AnonArray(binascii.unhexlify(j["data"]))
         interface = j['interface']
         indented("ser%u.write(%s)" % (interface, data_str))
     else:
         # assert 0
         print('# next_json: %s' % (j['type'], ))
Exemplo n.º 3
0
 def comment(self, s):
     indented('# %s' % (s, ))
Exemplo n.º 4
0
 def next_json(self, j, prefix=None):
     if j['type'] == 'read':
         interface = j['interface']
         data = j['data']
         n = len(data) / 2
         prefix = j['prefix']
         if self.ascii:
             indented("%u r %s: %s" %
                      (interface, n, binascii.unhexlify(data)))
         else:
             indented("%u r %s: 0x%s" % (interface, n, data))
             indented("  %s" % (binascii.hexlify(prefix, )))
     elif j['type'] == 'write':
         interface = j['interface']
         data = j['data']
         n = len(data) / 2
         if self.ascii:
             indented("%u w %s: %s" %
                      (interface, n, binascii.unhexlify(data)))
         else:
             indented("%u w %s: 0x%s" % (interface, n, data))
     elif j['type'] == 'SET_DATA':
         indented(
             "i%s SET_DATA: parity %s, stop bits %s, break %s" %
             (j['interface'], j['parity'], j['stopbits'], j['breakon']))
     else:
         indented("i%s %s: %s" % (j['interface'], j['type'], j))