Files
pqAutomationApp/docs/UCD-API文档/examples/work_with_packet_generation.py

94 lines
2.1 KiB
Python
Raw Permalink Normal View History

2026-07-02 17:16:18 +08:00
#
# Import UniTAP module.
#
import UniTAP
import time
#
# To initialize UniTAP library wrapper user should create UniTAP.TsiLib() object.
#
lUniTAP = UniTAP.TsiLib()
#
# For opening device, please, put serial number of the device as 8 symbol str or put index of device.
#
dev = lUniTAP.open(0)
2026-07-02 17:16:18 +08:00
# After opening device as in UCD Console device role should be selected.
# role = dev.select_role(UniTAP.dev.UCD422.HDMISourceHDMISink)
role = dev.select_role(UniTAP.dev.UCD323.HDMISource)
hdr10_drm_if = bytearray([
0x87, 0x01, 0x1A, 0x91,
0x02, 0x00,
0x34, 0x21, 0xAA, 0x9B,
0x96, 0x19, 0xFC, 0x08,
0x48, 0x8A, 0x08, 0x39,
0x13, 0x3D, 0x42, 0x40,
0xE8, 0x03,
0x32, 0x00,
0xE8, 0x03,
0x90, 0x01,
0x00, 0x00, 0x00, 0x00
])
role.hdtx.sdpg.add_packet(hdr10_drm_if)
# role.hdtx.sdpg.add_packet(bytearray([0x81, 0x01, 0x1B, 0x16, 0x8B, 0x84, 0x90, 0x40, 0x00, 0x00, 0x06, 0x64, 0x00, 0x00, 0x00, 0x00,
# 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
# 0x00, 0x00, 0x00, 0x00]))
# role.hdtx.sdpg.load_packet("UniTAP/dev/modules/dut_tests/cfg/hdr10/hdr10_edid.bin")
2026-07-02 17:16:18 +08:00
role.hdtx.sdpg.stop()
print(role.hdtx.sdpg.status())
time.sleep(5)
role.hdtx.sdpg.start()
print(role.hdtx.sdpg.status())
#
# Since the 3.5 version, TsiLib and TSIDevice objects have the option to be closed earlier.
# TSIDevice can be closed with the TsiLib method close(). TsiLib can be closed with cleanup().
# Clean up will close all opened devices and block ability to open any devices
# with same TsiLib object.
#
lUniTAP.close(dev)
lUniTAP.cleanup()
def calc_infoframe_checksum(header, payload):
return (-sum(header) - sum(payload)) & 0xFF
# header = [0x87, 0x01, 0x1A]
# payload = [
# 0x02, 0x00,
# 0x34, 0x21, 0xAA, 0x9B,
# 0x96, 0x19, 0xFC, 0x08,
# 0x48, 0x8A, 0x08, 0x39,
# 0x13, 0x3D, 0x42, 0x40,
# 0xE8, 0x03,
# 0x32, 0x00,
# 0xE8, 0x03,
# 0x90, 0x01
# ]
# checksum = calc_infoframe_checksum(header, payload)
# print(hex(checksum)) # 0x91