from hth6400 import ( SetAll, set_all_uart, set_all_i2c, snapshot_reads, uart_frame, decode_frame, decode_ack_nack, decode_snapshot, ) v = SetAll((0,) * 18 + (100,) * 6, (20, 20, 20, 30), (20, 20, 20, 10)) assert set_all_uart(v).hex().upper() == 'A55A01200000000000000000000000000000000000006464646464641414141E1414140A4205' assert len(set_all_i2c(v)) == 2 assert [x[2] for x in snapshot_reads(201)] == [64, 64, 64, 9] ack = uart_frame(0x06, bytes((1, 0x01, 0, 0))) assert decode_frame(ack)[0] == 0x06 assert decode_ack_nack(ack) == { 'ok': True, 'request': 1, 'status': 0, 'status_name': 'OK', 'detail': 0, } snapshot = uart_frame(0x82, bytes(range(16))) assert decode_snapshot(snapshot, 16) == bytes(range(16)) print('PY6400_PASS')