def __init__(self, serial, ifno, epno): threading.Thread.__init__(self) TPADecoder.__init__(self) self.dev = usb.core.find(idVendor=0x1d50, idProduct=0x6018, custom_match=lambda d: check_serial(d, serial) ) config = self.dev[0] iface = tuple(config)[ifno] self.endp = tuple(iface)[0] self.lock = threading.RLock() self.rawfile = None self.register_opcode(0x70, 0xFF, printopcode, "OVERFLOW!")
def unregister_opcode(self, code, mask): self.lock.acquire() TPADecoder.unregister_opcode(self, code, mask) self.lock.release()
def register_opcode(self, code, mask, func, *args): self.lock.acquire() def op_proxy(dec, op, param, *args): gdb.post_event(lambda: func(dec, op, param, *args)) TPADecoder.register_opcode(self, code, mask, op_proxy, *args) self.lock.release()