예제 #1
0
    def locate_message(self, mem, message_id):
        """Return the location where the messege data is stored.

        Args:
          mem (mmap): The input stream of ROM.
          message_id: An ID.

        Returns:
          TBW
        """

        count, group = self._do_select_message_group(message_id)

        mem.seek(self.mapper.from_cpu(self.addr_group) + group)
        buffer1 = mem.read(3)

        # In fact, the array in RHS is
        # {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}.
        shift = self.shiftbit_array[buffer1[0] & 0x07]
        addr = get_bits(buffer1, 0, 0xFFFFF8) + self.addr_message
        delims = self.delimiters

        # The loop counter depends on message id & 0x0007.
        for _ in range(count):
            code = b'\xFFFF' # dummy value
            while not code in delims:
                addr, shift, code = self.decode(mem, addr, shift)

        return addr, shift
예제 #2
0
 def test_get_bits(self):
     """Test function dqutils.bit.get_bits."""
     data = [i for i in range(0x06)]
     self.assertEqual(get_bits(data, 0, 0xFF00), 0x0001)
     self.assertEqual(get_bits(data, 1, 0xFFFF), 0x0201)
     self.assertEqual(get_bits(data, 0, 0x0100), 0x0001)
예제 #3
0
 def _do_get_value(self, byte_string):
     return get_bits(byte_string, self.offset, self.mask)