예제 #1
0
    def render(self, **kwargs):
        self.u.data.sof = ord(SOF)
        self.u.data.length = HEADER_LEN + kwargs.get('data_length') + DATA_CRC_LEN
        self.u.data.ver = VER
        self.u.data.session = kwargs.get('session')
        self.u.data.ack = kwargs.get('ack')
        self.u.data.res0 = 0
        self.u.data.pad = kwargs.get('pad')
        self.u.data.enc = kwargs.get('enc')
        self.u.data.res1 = 0
        self.u.data.seq = kwargs.get('seq')
        self.u.data.crc16 = 0

        buf = ''.join([chr(x) for x in self.u.buf])
        self.u.data.crc16 = calcCrc16(buf[:10])
        return ''.join([chr(x) for x in self.u.buf])
예제 #2
0
    def render(self, **kwargs):
        self.u.data.sof = ord(SOF)
        self.u.data.length = HEADER_LEN + kwargs.get('data_length') + DATA_CRC_LEN
        self.u.data.ver = VER
        self.u.data.session = kwargs.get('session')
        self.u.data.ack = kwargs.get('ack')
        self.u.data.res0 = 0
        self.u.data.pad = kwargs.get('pad')
        self.u.data.enc = kwargs.get('enc')
        self.u.data.res1 = 0
        self.u.data.seq = kwargs.get('seq')
        self.u.data.crc16 = 0

        buf = ''.join([chr(x) for x in self.u.buf])
        self.u.data.crc16 = calcCrc16(buf[:10])
        return ''.join([chr(x) for x in self.u.buf])
예제 #3
0
    def parse(self, buf):
        for i in range(HEADER_LEN):
            self.u.buf[i] = ord(buf[i])

        crcval = calcCrc16(buf[:10])
        self.crc_check_passed = (crcval == self.u.data.crc16)
예제 #4
0
    def parse(self, buf):
        for i in range(HEADER_LEN):
            self.u.buf[i] = ord(buf[i])

        crcval = calcCrc16(buf[:10])
        self.crc_check_passed = (crcval == self.u.data.crc16)