| 12345678910111213141516171819202122232425 |
- #!/usr/bin/env python3
- from pathlib import Path
- import sys
- sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "python"))
- from hth6400 import (
- SetAll, set_all_uart, set_all_i2c, get_snapshot_i2c,
- snapshot_reads, uart_frame, decode_ack_nack,
- )
- value = SetAll(
- ptc=(0,) * 18 + (100,) * 6,
- front=(20, 20, 20, 30),
- rear=(20, 20, 20, 10),
- )
- print("UART_SET_ALL", set_all_uart(value).hex().upper())
- for index, (address, write, read_length) in enumerate(set_all_i2c(value)):
- print("I2C[%d] address=0x%02X write=%s read=%d" %
- (index, address, write.hex().upper(), read_length))
- address, write, read_length = get_snapshot_i2c()
- print("I2C_GET address=0x%02X write=%s read=%d" %
- (address, write.hex().upper(), read_length))
- print("I2C_SNAPSHOT_READS", [(tx[1].hex().upper(), tx[2]) for tx in snapshot_reads(199, 64)])
- ack = uart_frame(0x06, bytes((1, 0x01, 0, 0)))
- print("ACK", decode_ack_nack(ack))
|