Beispiel #1
0
    class __RXCSniffService(baseService):
        import crcmod
        data_crc = staticmethod(crcmod.mkCrcFun(0x18005))

        def getNeededSizeForMagic(self, b):
            if b == 0xA0:
                return 5
            return 1

        def __init__(self):
            self.last_rxcmd = 0

            self.usbbuf = []

            self.highspeed = False

            self.ui = USBInterpreter(self.highspeed)

            self.handlers = [self.handle_usb_verbose]

            self.got_start = False


        def matchMagic(self, byt):
            return byt == 0xAC or byt == 0xAD or byt == 0xA0

        def getPacketSize(self, buf):
            if buf[0] != 0xA0:
                return 2
            else:
                #print("SIZING: %s" % " ".join("%02x" %i for i in buf))
                return (buf[4] << 8 | buf[3]) + 8


        def consume(self, buf):
            if buf[0] == 0xA0:
                flags = buf[1] | buf[2] << 8

                ts = buf[5] | buf[6] << 8 | buf[7] << 16

                if flags != 0 and flags != HF0_FIRST and flags != HF0_LAST:
                    print("PERR: %04X (%s)" % (flags, decode_flags(flags)))
               
                if flags & HF0_FIRST:
                    self.got_start = True

                if self.got_start:
                    self.handle_usb(ts, buf[8:], flags)

                if flags & HF0_LAST:
                    self.got_start = False

        def handle_usb(self, ts, buf, flags):
            for handler in self.handlers:
                handler(ts, buf, flags)

        def handle_usb_verbose(self, ts, buf, flags):
#                ChandlePacket(ts, flags, buf, len(buf))
                self.ui.handlePacket(ts, buf, flags)
Beispiel #2
0
        def __init__(self):
            self.last_rxcmd = 0

            self.usbbuf = []

            self.highspeed = False

            self.ui = USBInterpreter(self.highspeed)

            self.handlers = [self.handle_usb_verbose]

            self.got_start = False