Exemplo n.º 1
0
    def check_frame(self):
        """ Check and decode the next frame

        :returns: True if we successful, False otherwise
        """
        start = self.buffer.find(self.__start)
        if start == -1:
            return False
        if start > 0:  # go ahead and skip old bad data
            self.buffer = self.buffer[start:]
            start = 0

        end = self.buffer.find(self.__end)
        if end != -1:
            self.header['len'] = end
            self.header['uid'] = int(self.buffer[1:3], 16)
            self.header['lrc'] = int(self.buffer[end - 2:end], 16)
            data = a2b_hex(self.buffer[start + 1:end - 2])
            return check_lrc(data, self.header['lrc'])
        return False
Exemplo n.º 2
0
    def check_frame(self):
        """ Check and decode the next frame

        :returns: True if we successful, False otherwise
        """
        start = self.buffer.find(self.__start)
        if start == -1:
            return False
        if start > 0:  # go ahead and skip old bad data
            self.buffer = self.buffer[start:]
            start = 0

        end = self.buffer.find(self.__end)
        if end != -1:
            self.header['len'] = end
            self.header['uid'] = int(self.buffer[1:3], 16)
            self.header['lrc'] = int(self.buffer[end - 2:end], 16)
            data = a2b_hex(self.buffer[start + 1:end - 2])
            return check_lrc(data, self.header['lrc'])
        return False
Exemplo n.º 3
0
 def test_longitudinal_redundancy_check(self):
     """ Test the longitudinal redundancy check code """
     self.assertTrue(check_lrc(self.data, 0x1c))
     self.assertTrue(check_lrc(self.string, 0x0c))
Exemplo n.º 4
0
 def test_longitudinal_redundancy_check(self):
     """ Test the longitudinal redundancy check code """
     self.assertTrue(check_lrc(self.data, 0x1c))
     self.assertTrue(check_lrc(self.string, 0x0c))