Beispiel #1
0
 def test_01_Nibble2Hex(self):
     """Convert nibbles to the hex char representation
     """
     l_hex = BuildCommand._nibble_to_hex(0x00)
     self.assertEqual(l_hex, ord('0'))
     #
     l_hex = BuildCommand._nibble_to_hex(0x07)
     self.assertEqual(l_hex, ord('7'))
     #
     l_hex = BuildCommand._nibble_to_hex(0x0A)
     self.assertEqual(l_hex, 0x41)
     #
     l_hex = BuildCommand._nibble_to_hex(0x0F)
     self.assertEqual(l_hex, 0x46)
Beispiel #2
0
 def test_01_Nibble2Hex(self):
     """Convert nibbles to the hex char representation
     """
     l_hex = BuildCommand._nibble_to_hex(0x00)
     self.assertEqual(l_hex, ord("0"))
     #
     l_hex = BuildCommand._nibble_to_hex(0x07)
     self.assertEqual(l_hex, ord("7"))
     #
     l_hex = BuildCommand._nibble_to_hex(0x0A)
     self.assertEqual(l_hex, 0x41)
     #
     l_hex = BuildCommand._nibble_to_hex(0x0F)
     self.assertEqual(l_hex, 0x46)
Beispiel #3
0
 def test_02_Byte2Hex(self):
     l_str = BuildCommand._byte_to_2chars(0x00)
     self.assertEqual(l_str, b'\x30\x30')
     self.assertEqual(l_str, '00')
     l_str = BuildCommand._byte_to_2chars(0x08)
     self.assertEqual(l_str, '08')
     l_str = BuildCommand._byte_to_2chars(0x0F)
     self.assertEqual(l_str, '0F')
     l_str = BuildCommand._byte_to_2chars(0x80)
     self.assertEqual(l_str, '80')
     l_str = BuildCommand._byte_to_2chars(0x77)
     self.assertEqual(l_str, '77')
     l_str = BuildCommand._byte_to_2chars(0xff)
     self.assertEqual(l_str, 'FF')
Beispiel #4
0
 def test_02_Byte2Hex(self):
     l_str = BuildCommand._byte_to_2chars(0x00)
     self.assertEqual(l_str, b"\x30\x30")
     self.assertEqual(l_str, "00")
     l_str = BuildCommand._byte_to_2chars(0x08)
     self.assertEqual(l_str, "08")
     l_str = BuildCommand._byte_to_2chars(0x0F)
     self.assertEqual(l_str, "0F")
     l_str = BuildCommand._byte_to_2chars(0x80)
     self.assertEqual(l_str, "80")
     l_str = BuildCommand._byte_to_2chars(0x77)
     self.assertEqual(l_str, "77")
     l_str = BuildCommand._byte_to_2chars(0xFF)
     self.assertEqual(l_str, "FF")
Beispiel #5
0
 def test_03_CalcChecksum(self):
     l_ba = BuildCommand._calculate_checksum(b'\x11')
     self.assertEqual(l_ba, ord(b'\xEF'))
     #
     l_ba = BuildCommand._calculate_checksum(b'\xD4')
     self.assertEqual(l_ba, ord(b'\x2C'))
     #
     l_ba = BuildCommand._calculate_checksum(b'\x70\x03')
     self.assertEqual(l_ba, ord(b'\x8D'))
     #
     l_ba = BuildCommand._calculate_checksum(b'\xA1\xA3')
     self.assertEqual(l_ba, ord(b'\xBC'))
     #
     l_ba = BuildCommand._calculate_checksum(b'\x51\xA3\x6A')
     # print('5 {} {:x}'.format(l_ba, l_ba))
     self.assertEqual(l_ba, ord(b'\xA2'))
     #
     l_ba = BuildCommand._calculate_checksum(b'\x35\x23\x24\x9f')
     # print('6 {} {:x}'.format(l_ba, l_ba))
     self.assertEqual(l_ba, ord(b'\xE5'))
Beispiel #6
0
 def test_03_CalcChecksum(self):
     l_ba = BuildCommand._calculate_checksum(b"\x11")
     self.assertEqual(l_ba, ord(b"\xEF"))
     #
     l_ba = BuildCommand._calculate_checksum(b"\xD4")
     self.assertEqual(l_ba, ord(b"\x2C"))
     #
     l_ba = BuildCommand._calculate_checksum(b"\x70\x03")
     self.assertEqual(l_ba, ord(b"\x8D"))
     #
     l_ba = BuildCommand._calculate_checksum(b"\xA1\xA3")
     self.assertEqual(l_ba, ord(b"\xBC"))
     #
     l_ba = BuildCommand._calculate_checksum(b"\x51\xA3\x6A")
     # print('5 {} {:x}'.format(l_ba, l_ba))
     self.assertEqual(l_ba, ord(b"\xA2"))
     #
     l_ba = BuildCommand._calculate_checksum(b"\x35\x23\x24\x9f")
     # print('6 {} {:x}'.format(l_ba, l_ba))
     self.assertEqual(l_ba, ord(b"\xE5"))
Beispiel #7
0
 def test_09_Register(self):
     l_ba = BuildCommand.write_register_command(self.m_controller_obj,
                                                b'\x70', b'\x03')
     self.assertEqual(l_ba, (b'\x17\x70\x03\x8D\x0D'))
Beispiel #8
0
 def test_06_Convert(self):
     l_ba = BuildCommand._assemble_regwrite(0x70, b'\x03')
     l_cv = BuildCommand._convert_pim(l_ba)
     self.assertEqual(l_cv, (b'\x70\x03\x8D'))
Beispiel #9
0
 def test_05_AssembleCommand(self):
     l_ba = BuildCommand._assemble_regwrite(0x70, b'\03')
     self.assertEqual(l_ba, b'\x70\x03\x8D')
Beispiel #10
0
 def test_04_AppendChecksum(self):
     l_ba = BuildCommand._append_checksum(b'\x70\x03')
     self.assertEqual(l_ba, b'\x70\x03\x8D')
Beispiel #11
0
 def test_09_Register(self):
     l_ba = BuildCommand.write_register_command(self.m_controller_obj, b"\x70", b"\x03")
     self.assertEqual(l_ba, (b"\x17\x70\x03\x8D\x0D"))
Beispiel #12
0
 def test_06_Convert(self):
     l_ba = BuildCommand._assemble_regwrite(0x70, b"\x03")
     l_cv = BuildCommand._convert_pim(l_ba)
     self.assertEqual(l_cv, (b"\x70\x03\x8D"))
Beispiel #13
0
 def test_05_AssembleCommand(self):
     l_ba = BuildCommand._assemble_regwrite(0x70, b"\03")
     self.assertEqual(l_ba, b"\x70\x03\x8D")
Beispiel #14
0
 def test_04_AppendChecksum(self):
     l_ba = BuildCommand._append_checksum(b"\x70\x03")
     self.assertEqual(l_ba, b"\x70\x03\x8D")