更新UCD-API库及文档
This commit is contained in:
78
docs/UCD-API文档/examples/calculate_crc_from_file.py
Normal file
78
docs/UCD-API文档/examples/calculate_crc_from_file.py
Normal file
@@ -0,0 +1,78 @@
|
||||
import UniTAP
|
||||
import copy
|
||||
from PIL import Image
|
||||
from UniTAP.dev.ports.modules.internal_utils import uicl_image_from_vm_and_data
|
||||
from UniTAP.libs.lib_dscl.dscl_utils import dscl_data_processing
|
||||
from UniTAP.libs.lib_uicl.uicl import UICL_CalculateCRC16
|
||||
from UniTAP.libs.lib_uicl.uicl_types import UICL_Image, UICL_CRC16, UICL_SUCCESS
|
||||
from UniTAP.libs.lib_dscl import dscl_image_calculate_crc
|
||||
from UniTAP.libs.lib_uicl.uicl_utils import image_convert_to_parameters, uicl_parameters_from_vm
|
||||
|
||||
|
||||
def data_from_image_file(target_video_mode: UniTAP.VideoMode, path: str) -> UICL_Image:
|
||||
current_video_mode = copy.deepcopy(target_video_mode)
|
||||
target_size = (target_video_mode.timing.hactive, target_video_mode.timing.vactive)
|
||||
|
||||
image = Image.open(path)
|
||||
image = image.resize(target_size)
|
||||
image = image.convert('RGB')
|
||||
data = bytearray([x for sets in list(image.getdata()) for x in sets])
|
||||
|
||||
current_video_mode.color_info.color_format = UniTAP.ColorInfo.ColorFormat.CF_RGB
|
||||
current_video_mode.color_info.bpc = 8
|
||||
current_video_mode.color_info.colorimetry = UniTAP.ColorInfo.Colorimetry.CM_sRGB
|
||||
|
||||
image = uicl_image_from_vm_and_data(current_video_mode, data)
|
||||
if current_video_mode != target_video_mode:
|
||||
image = image_convert_to_parameters(image, uicl_parameters_from_vm(target_video_mode))
|
||||
|
||||
return image
|
||||
|
||||
|
||||
def image_calculate_crc(src_image):
|
||||
crc = UICL_CRC16()
|
||||
|
||||
result = UICL_CalculateCRC16(src_image, crc)
|
||||
|
||||
assert result >= UICL_SUCCESS, f"Calculation CRC failed with error {result}"
|
||||
|
||||
return crc.R, crc.G, crc.B
|
||||
|
||||
|
||||
def calculate_dsc_image_crc(file_path: str):
|
||||
with open(file_path, "rb") as dsc_file:
|
||||
data = bytearray(dsc_file.read())
|
||||
|
||||
return dscl_image_calculate_crc(dscl_data_processing(data))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
#
|
||||
# Case 1: Normal image
|
||||
#
|
||||
file_name = "C:\\Work\\AdditionWorkFiles\\BinData\\Images\\colorbars.bmp"
|
||||
|
||||
# Fill your parameters of destination color mode
|
||||
color_mode = UniTAP.ColorInfo()
|
||||
color_mode.bpc = 8
|
||||
color_mode.color_format = UniTAP.ColorInfo.ColorFormat.CF_RGB
|
||||
color_mode.colorimetry = UniTAP.ColorInfo.Colorimetry.CM_sRGB
|
||||
|
||||
timing = UniTAP.Timing()
|
||||
timing.hactive = 1920
|
||||
timing.vactive = 1080
|
||||
|
||||
image_video_mode = UniTAP.VideoMode(timing=timing, color_info=color_mode)
|
||||
|
||||
crc_0, crc_1, crc_2 = image_calculate_crc(data_from_image_file(image_video_mode, file_name))
|
||||
|
||||
print(f"CRC 0 - {hex(crc_0)}, CRC 1 - {hex(crc_1)}, CRC 2 - {hex(crc_2)}")
|
||||
|
||||
#
|
||||
# Case 2: DSC Image
|
||||
#
|
||||
file_name = "C:\\Work\\AdditionWorkFiles\\BinData\\DSC\\1920x1080_RGB444_BPY_bpc8_bpp128_10slicew_10sliceh_9lb_v12.dsc"
|
||||
|
||||
dsc_crc_0, dsc_crc_1, dsc_crc_2 = calculate_dsc_image_crc(file_name)
|
||||
|
||||
print(f"DSC CRC 0 - {hex(dsc_crc_0)}, DSC CRC 1 - {hex(dsc_crc_1)}, DSC CRC 2 - {hex(dsc_crc_2)}")
|
||||
152
docs/UCD-API文档/examples/check_crc_rx_and_tx_sides.py
Normal file
152
docs/UCD-API文档/examples/check_crc_rx_and_tx_sides.py
Normal file
@@ -0,0 +1,152 @@
|
||||
# =================================================================================================
|
||||
# This script is written to check the CRC values on the TX and RX sides,
|
||||
# as well as check the CRC for captured video frames.
|
||||
# The main check is performed on standard patterns, but you can also use custom images.
|
||||
# In order to check the DSC of an image, you need to change the functions to select the CRC values,
|
||||
# as well as take a value from a stream variable link.status.stream(stream_number).dsc_crc.
|
||||
# =================================================================================================
|
||||
|
||||
|
||||
# Import UniTAP and others module.
|
||||
import UniTAP
|
||||
import time
|
||||
from UniTAP.utils import calculate_crc
|
||||
|
||||
max_streams = 1
|
||||
log_fid = open("rb_testing.log", 'w')
|
||||
|
||||
|
||||
# =================================================================================================
|
||||
# Function. Setting and applying Pattern Generator (PG)
|
||||
# =================================================================================================
|
||||
def apply_PG(role, max_streams, timing, bpc, color_format, pg_progress_max, pg_progress_cur, pattern):
|
||||
color_mode = UniTAP.ColorInfo()
|
||||
if color_format == color_mode.ColorFormat.CF_RGB:
|
||||
color_mode.bpc = bpc
|
||||
color_mode.dynamic_range = color_mode.DynamicRange.DR_VESA
|
||||
else:
|
||||
color_mode.dynamic_range = color_mode.DynamicRange.DR_CTA
|
||||
# if bpc == 6:
|
||||
# return 0
|
||||
color_mode.bpc = bpc
|
||||
color_mode.color_format = color_format
|
||||
color_mode.colorimetry = UniTAP.ColorInfo.Colorimetry.CM_ITUR_BT601
|
||||
if not color_mode.is_valid():
|
||||
print("Color mode " + color_mode.__str__() + " is not valid")
|
||||
exit(1)
|
||||
video_mode = UniTAP.VideoMode(timing=timing, color_info=color_mode)
|
||||
for stream in range(max_streams):
|
||||
role.pg[stream].set_vm(vm=video_mode)
|
||||
role.pg[stream].set_pattern(pattern=pattern)
|
||||
role.pg[stream].apply()
|
||||
# logger.debug("Set video mode: " + video_mode.__str__())
|
||||
# print("Set video mode: " + video_mode.__str__())
|
||||
progress(pg_progress_max, pg_progress_cur, "Timing: {}".format(video_mode), log_fid)
|
||||
time.sleep(0.5)
|
||||
|
||||
|
||||
# =================================================================================================
|
||||
# Function. TX, RX CRCs comparison
|
||||
# =================================================================================================
|
||||
def check_CRCs_the_same(roles, max_streams, log_fid):
|
||||
for stream in range(max_streams):
|
||||
tx_crc = list(map(hex, roles.dptx.link.status.stream(stream).crc))
|
||||
rx_crc = list(map(hex, roles.dprx.link.status.stream(stream).crc))
|
||||
if tx_crc != rx_crc:
|
||||
msg = "@Error: stream " + stream.__str__() + ": CRCs are different: TX: " + tx_crc.__str__() + "; RX: " + rx_crc.__str__()
|
||||
print(msg)
|
||||
log_fid.write(msg + '\n')
|
||||
|
||||
|
||||
# =================================================================================================
|
||||
# Function. Check CRCs on captured frames: stability and equality with dprx.stream.crc
|
||||
# =================================================================================================
|
||||
def check_capturing(log_fid):
|
||||
buffers = 3
|
||||
role_rx.video_capturer.start(frames_count=buffers)
|
||||
role_rx.video_capturer.stop()
|
||||
result = role_rx.video_capturer.capture_result
|
||||
stream_crc = list(map(hex, role_rx.link.status.stream(0).crc))
|
||||
bin_fid = open('buf.dat', 'bw')
|
||||
bin_fid.write(result.buffer[0].data)
|
||||
bin_fid.close()
|
||||
for b in range(buffers):
|
||||
capt_crc = list(map(hex, calculate_crc(result.buffer[b])))
|
||||
if stream_crc != capt_crc:
|
||||
msg = "@Error: stream 0 CRCs are different: RX: " + stream_crc.__str__() + "; Captured: " + capt_crc.__str__()
|
||||
print(msg)
|
||||
log_fid.write(msg + '\n')
|
||||
|
||||
|
||||
# =================================================================================================
|
||||
# Function. Progress
|
||||
# =================================================================================================
|
||||
def progress(max, cur, msg='', log_fid=0):
|
||||
print("Progress: %3.2f%%: %s" % (cur * 100 / max, msg), end='\n')
|
||||
log_fid.write(msg + '\n')
|
||||
|
||||
|
||||
# =================================================================================================
|
||||
# MAIN
|
||||
# =================================================================================================
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Open roles and others init routines
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
if __name__ == '__main__':
|
||||
# init UniTAP library wrapper
|
||||
lUniTAP = UniTAP.TsiLib()
|
||||
# open device and set the role
|
||||
serial_number = "2150C474"
|
||||
dev = lUniTAP.open(serial_number)
|
||||
roles = dev.select_role(UniTAP.dev.UCD500.USBCSourceUSBCSink)
|
||||
role_tx = roles.dptx
|
||||
role_rx = roles.dprx
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Setting up links
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# make LT
|
||||
role_tx.link.start_link_training()
|
||||
|
||||
# wait some time after LT
|
||||
time.sleep(2)
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Get all video modes
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
timing_manager = role_tx.pg.timing_manager
|
||||
color_mode = UniTAP.ColorInfo()
|
||||
# set color_formats list
|
||||
color_formats = [
|
||||
# color_mode.ColorFormat.CF_RGB,
|
||||
# color_mode.ColorFormat.CF_YCbCr_444,
|
||||
color_mode.ColorFormat.CF_YCbCr_422,
|
||||
# color_mode.ColorFormat.CF_YCbCr_420
|
||||
]
|
||||
|
||||
# set pattern (can be value from defaults, like UniTAP.VideoPattern.SolidWhite) or name of image
|
||||
pattern = UniTAP.VideoPattern.SolidWhite
|
||||
|
||||
# pattern = "image.png"
|
||||
|
||||
# set bpc list
|
||||
color_bpcs = [6, 8, 10, 12, 16]
|
||||
|
||||
# get RB timings only (it was a test case of Maxim Zaitsev)
|
||||
rb_timings = []
|
||||
for t in timing_manager.get_all():
|
||||
if t.reduce_blanking > 0:
|
||||
rb_timings.append(t)
|
||||
|
||||
pg_progress_max = len(rb_timings) * len(color_formats) * len(color_bpcs)
|
||||
pg_progress_cur = 0
|
||||
for t in rb_timings:
|
||||
for cf in color_formats:
|
||||
for bpc in color_bpcs:
|
||||
if cf != color_mode.ColorFormat.CF_RGB and bpc == 6:
|
||||
pass
|
||||
else:
|
||||
apply_PG(role_tx, max_streams, t, bpc, cf, pg_progress_max, pg_progress_cur, pattern)
|
||||
check_CRCs_the_same(roles, max_streams, log_fid)
|
||||
check_capturing(log_fid)
|
||||
pg_progress_cur += 1
|
||||
log_fid.close()
|
||||
95
docs/UCD-API文档/examples/generate_custom_dsc_and_load.py
Normal file
95
docs/UCD-API文档/examples/generate_custom_dsc_and_load.py
Normal file
@@ -0,0 +1,95 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
|
||||
import UniTAP
|
||||
from UniTAP.utils import encode_video_frame, calculate_dsc_slice_size
|
||||
from UniTAP.common import get_vf_from_image, CompressionInfo
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
role = dev.select_role(UniTAP.dev.UCD400.DPSourceDPSink)
|
||||
# role = dev.select_role(UniTAP.dev.UCD500.DPSourceDPSink)
|
||||
|
||||
#
|
||||
# For using our predefined device specific timings, you can use 'timing manager' with which you can get them.
|
||||
#
|
||||
timing_manager = role.dptx.pg.timing_manager
|
||||
|
||||
color_mode = UniTAP.ColorInfo()
|
||||
color_mode.color_format = UniTAP.ColorInfo.ColorFormat.CF_RGB
|
||||
color_mode.bpc = 8
|
||||
color_mode.colorimetry = UniTAP.ColorInfo.Colorimetry.CM_sRGB
|
||||
|
||||
target_width = 1920
|
||||
target_height = 1080
|
||||
path_custom_image = "Your_Path_To_Image.jpg"
|
||||
|
||||
vf = get_vf_from_image(path_custom_image, target_width, target_height)
|
||||
|
||||
params = CompressionInfo()
|
||||
params.color_format = CompressionInfo.DscColorFormat.CF_RGB
|
||||
params.bpp = 128
|
||||
params.version = (1, 2)
|
||||
params.v_slice_size = calculate_dsc_slice_size(target_width, 4)
|
||||
params.h_slice_size = calculate_dsc_slice_size(target_height, 4)
|
||||
params.buffer_bit_depth = vf.color_info.bpc + 1
|
||||
|
||||
dsc_vf = encode_video_frame(vf, params)
|
||||
|
||||
video_mode = UniTAP.VideoMode(timing=timing_manager.get_cta(76), color_info=color_mode)
|
||||
|
||||
caps = role.dprx.link.capabilities.link_caps_status()
|
||||
caps.dsc = True
|
||||
caps.fec = True
|
||||
role.dprx.link.capabilities.set(caps)
|
||||
|
||||
role.dptx.link.start_link_training()
|
||||
|
||||
role.dptx.pg.set_vm(video_mode)
|
||||
|
||||
# Also you can put image path (dsc image path also) to function 'set_pattern' as argument.
|
||||
# path_custom_image = "Your_Path_To_Image.jpg"
|
||||
# role.dptx.pg.set_pattern(path_custom_image)
|
||||
role.dptx.pg.set_pattern(dsc_vf)
|
||||
role.dptx.pg.apply()
|
||||
res_app = role.dptx.pg.status().error
|
||||
print(f"Stream {0} - Apply {res_app.__str__()}")
|
||||
|
||||
role.dprx.video_capturer.start()
|
||||
dsc_captured_frame = role.dprx.video_capturer.pop_element()
|
||||
role.dprx.video_capturer.stop()
|
||||
|
||||
print(dsc_captured_frame.is_compressed())
|
||||
print(dsc_captured_frame)
|
||||
|
||||
role.dptx.pg.set_pattern(UniTAP.VideoPattern.ColorSquares)
|
||||
role.dptx.pg.apply()
|
||||
res_app = role.dptx.pg.status().error
|
||||
print(f"Stream {0} - Apply {res_app.__str__()}")
|
||||
|
||||
role.dprx.video_capturer.start()
|
||||
captured_frame = role.dprx.video_capturer.pop_element()
|
||||
role.dprx.video_capturer.stop()
|
||||
print(captured_frame.is_compressed())
|
||||
print(captured_frame)
|
||||
|
||||
#
|
||||
# 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()
|
||||
193
docs/UCD-API文档/examples/opf_18.py
Normal file
193
docs/UCD-API文档/examples/opf_18.py
Normal file
@@ -0,0 +1,193 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
import UniTAP
|
||||
|
||||
|
||||
def ofp_15_handler(requst_text: str) -> UniTAP.OPFDialogAnswer:
|
||||
print(requst_text)
|
||||
return UniTAP.OPFDialogAnswer.PROCEED
|
||||
|
||||
|
||||
def ofp_17_handler(requst_text: str) -> UniTAP.OPFDialogAnswer:
|
||||
print(requst_text)
|
||||
return UniTAP.OPFDialogAnswer.PROCEED
|
||||
|
||||
|
||||
# Define OPF 18 handler function. This function will be called when OPF 18 will ask for some user
|
||||
# actions. In this function parameters will be same as in operator feedback dialog in UCD Console.
|
||||
# Description for parameters can be found in TSI manual. OPF function must declare return value
|
||||
# via "-> UniTAP.OPFDialogAnswer" (this is verification and reminder for developer that function must
|
||||
# return specific value). Otherwise, dialog will be aborted by UniTAP module.
|
||||
|
||||
|
||||
def ofp_18_handler(res_x, res_y, res_frate, res_bpc, col_format, col_range, col_yc, tim_std) \
|
||||
-> UniTAP.OPFDialogAnswer:
|
||||
|
||||
print(res_x, res_y, res_frate, res_bpc, col_format, col_range, col_yc, tim_std)
|
||||
#
|
||||
# Call external executable for processing OPF dialog.
|
||||
#
|
||||
return UniTAP.OPFDialogAnswer.PROCEED
|
||||
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
|
||||
# After opening device as in UCD Console device role should be selected. Right now UniTAP module support:
|
||||
# UCD323, UCD340(but without PD), UCD400, UCD422, UCD500
|
||||
|
||||
role = dev.select_role(UniTAP.dev.UCD424.USBCSourceUSBCSink)
|
||||
# role = dev.select_role(UniTAP.dev.UCD500.DPSourceDPSink)
|
||||
|
||||
#
|
||||
# Assign early defined function ofp_18_handler for handling OPF 18 dialog.
|
||||
#
|
||||
# dev.opf_handler.assign_function_for_opf_id(6, ofp_6_handler)
|
||||
# dev.opf_handler.assign_function_for_opf_id(10, ofp_10_handler)
|
||||
dev.opf_handler.assign_function_for_opf_id(15, ofp_15_handler)
|
||||
dev.opf_handler.assign_function_for_opf_id(17, ofp_17_handler)
|
||||
dev.opf_handler.assign_function_for_opf_id(18, ofp_18_handler)
|
||||
|
||||
#
|
||||
# Test running.
|
||||
#
|
||||
|
||||
# To select required test group please use UniTAP.TestGroupId enum. In this enum presented all tests for
|
||||
# all possible devices. For first run good to check is required group is available on your device.
|
||||
# To do this use required port from "role" your need object dut_tests.
|
||||
# This object should be used as I/O for any interation with DUT tests. To get number of test in group
|
||||
# please use method number_tests_in_group and put UniTAP.TestGroupId as parameter.
|
||||
|
||||
print(role.dut_tests.number_tests_in_group(UniTAP.TestGroupId.DP_RX_LL_CTS_DSC))
|
||||
|
||||
|
||||
# Next step is getting default parameters for test group. Since in UCD Console default parameters
|
||||
# loaded automatically in python wrapper user should load this parameters via special method of
|
||||
# dut_tests module: get_default_parameters.
|
||||
|
||||
params = role.dut_tests.get_default_parameters(UniTAP.Dp14SourceDUTTestParam)
|
||||
|
||||
params.general.dut_caps.dut_caps_flags.dsc_supported = True
|
||||
params.general.dut_caps.dut_caps_flags.dsc_block_prediction_supported = False
|
||||
params.dsc.dsc_video_modes.clear_all()
|
||||
# params.dsc.dsc_video_modes.vm_3840x2160_60hz.cta = True
|
||||
# params.dsc.dsc_video_modes.vm_1920x1080_30hz.cta = True
|
||||
# params.dsc.dsc_video_modes.vm_5120x2160_30hz.cta = True
|
||||
params.dsc.dsc_video_modes.vm_7680x4320_30hz.cta = True
|
||||
params.dsc.dsc_version = (1, 2)
|
||||
params.dsc.dsc_max_slice = 4
|
||||
|
||||
#
|
||||
# For DSC Test 2
|
||||
#
|
||||
params.dsc.colorimetry.rgb_10bpc_vesa = True
|
||||
params.dsc.colorimetry.rgb_12bpc_vesa = True
|
||||
|
||||
#
|
||||
# For DSC Test 3
|
||||
#
|
||||
# params.dsc.colorimetry.ycbcr444_8bpc_cta_itu709 = True
|
||||
# params.dsc.colorimetry.ycbcr444_10bpc_cta_itu709 = True
|
||||
# params.dsc.colorimetry.ycbcr444_12bpc_cta_itu709 = True
|
||||
|
||||
#
|
||||
# For DSC Test 4
|
||||
#
|
||||
# params.dsc.colorimetry.ycbcr422_simple_8bpc_cta_itu709 = True
|
||||
# params.dsc.colorimetry.ycbcr422_simple_10bpc_cta_itu709 = True
|
||||
# params.dsc.colorimetry.ycbcr422_simple_12bpc_cta_itu709 = True
|
||||
|
||||
#
|
||||
# For DSC Test 5
|
||||
#
|
||||
# params.dsc.colorimetry.ycbcr422_8bpc_cta_itu709 = True
|
||||
# params.dsc.colorimetry.ycbcr422_10bpc_cta_itu709 = True
|
||||
# params.dsc.colorimetry.ycbcr422_12bpc_cta_itu709 = True
|
||||
|
||||
#
|
||||
# For DSC Test 6
|
||||
#
|
||||
# params.dsc.colorimetry.ycbcr420_8bpc_cta_itu709 = True
|
||||
# params.dsc.colorimetry.ycbcr420_10bpc_cta_itu709 = True
|
||||
# params.dsc.colorimetry.ycbcr420_12bpc_cta_itu709 = True
|
||||
|
||||
#
|
||||
# For Tests 4.4.1.1, 4.4.1.2, 4.4.2 (Mandatory RGB 6 and 8 bpc VESA)
|
||||
#
|
||||
# params.general.colorimetry.rgb_10bpc_vesa = True
|
||||
# params.general.colorimetry.rgb_6bpc_cta = True
|
||||
# params.general.colorimetry.rgb_8bpc_cta = True
|
||||
# params.general.colorimetry.ycbcr444_8bpc_cta_itu601 = True
|
||||
# params.general.colorimetry.ycbcr444_8bpc_cta_itu709 = True
|
||||
# params.general.colorimetry.ycbcr444_10bpc_cta_itu601 = True
|
||||
# params.general.colorimetry.ycbcr444_10bpc_cta_itu709 = True
|
||||
# params.general.colorimetry.ycbcr422_8bpc_cta_itu601 = True
|
||||
# params.general.colorimetry.ycbcr422_8bpc_cta_itu709 = True
|
||||
# params.general.colorimetry.ycbcr422_10bpc_cta_itu601 = True
|
||||
# params.general.colorimetry.ycbcr422_10bpc_cta_itu709 = True
|
||||
|
||||
#
|
||||
# Audio params
|
||||
#
|
||||
# params.audio.min_sample_rate = 44100
|
||||
# params.audio.max_sample_rate = 192000
|
||||
# params.audio.sample_size = 16
|
||||
# selected_channels = ["FL+FR", "RL+RR", "FLH+FRH"]
|
||||
# params.audio.min_ch_config_min_rate.select_channels(selected_channels, True)
|
||||
# params.audio.min_ch_config_max_rate.select_channels(selected_channels, True)
|
||||
# params.audio.max_ch_config_min_rate.select_channels(selected_channels, True)
|
||||
# params.audio.max_ch_config_max_rate.select_channels(selected_channels, True)
|
||||
|
||||
#
|
||||
# DUT test parameters will be changed soon. (Under development right now)
|
||||
#
|
||||
|
||||
# For Python Wrapper current way to configure DUT tests parameters is device whole test config to
|
||||
# 'tabs' with associated class(obj). For Source DUT DSC tests params.dsc_tab should be used.
|
||||
|
||||
|
||||
#
|
||||
# Running the test.
|
||||
#
|
||||
|
||||
# To run the test just call "run" method and pass to it 3 parameters. GroupID, index of the test in
|
||||
# that group and as last optional parameter: test parameters. If this parameter missed, test will be
|
||||
# start with default parameters.
|
||||
|
||||
role.dut_tests.run(UniTAP.TestGroupId.DP_RX_LL_CTS_DSC, 0, params)
|
||||
|
||||
#
|
||||
# Collecting test results and make HTML report
|
||||
#
|
||||
|
||||
# If needed test logs available as a result of method get_all_tests_results method. User will
|
||||
# receive TestResultObject which contain all logs and other useful information.
|
||||
|
||||
results = role.dut_tests.get_all_tests_results()
|
||||
|
||||
|
||||
# To create a HTML report please use make_report method. It required 2 parameters: 1) path to file
|
||||
# where report will be saved; 2) TestAdditionalInfo obj. TestAdditionalInfo contains information about
|
||||
# tested DUT device and should be filled with data by user.
|
||||
|
||||
role.dut_tests.make_report('./report', tested_by="Example", remarks="Remarks for test report.")
|
||||
|
||||
#
|
||||
# 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()
|
||||
69
docs/UCD-API文档/examples/reset_device.py
Normal file
69
docs/UCD-API文档/examples/reset_device.py
Normal file
@@ -0,0 +1,69 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
import time
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
serial_number = "2209C487"
|
||||
dev = lUniTAP.open(serial_number)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
role = dev.select_role(UniTAP.dev.UCD500.USBCSourceUSBCSink)
|
||||
|
||||
#
|
||||
# Reset will cause the device to go offline for up to 20 seconds.
|
||||
# This is not a blocking feature; you can continue using UniTAP.
|
||||
# Any status can be used to monitor the device's state, for example, "dprx.link.status.cable_state."
|
||||
# In the reset state, all values are 0.
|
||||
#
|
||||
cable_state = role.dprx.link.status.cable_state
|
||||
print(f"Cable state before reset: {cable_state}")
|
||||
print(f"Capabilities status before reset:\n{role.pdcrx.capabilities.status}")
|
||||
|
||||
dev.reset()
|
||||
print("Reset Device")
|
||||
|
||||
#
|
||||
# Check Cable state. After reset should be 0
|
||||
#
|
||||
cable_state = role.dprx.link.status.cable_state
|
||||
print(f"Cable state right away after reset: {cable_state}")
|
||||
print(f"Capabilities status right away after reset:\n{role.pdcrx.capabilities.status}")
|
||||
|
||||
#
|
||||
# Some code...
|
||||
#
|
||||
|
||||
#
|
||||
# Check Cable state again after pause 10 sec (Re-open device)
|
||||
#
|
||||
dev.close()
|
||||
print("Close device")
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
print("Re-open device")
|
||||
dev = lUniTAP.open(serial_number)
|
||||
role = dev.select_role(UniTAP.dev.UCD500.USBCSourceUSBCSink)
|
||||
|
||||
cable_state = role.dprx.link.status.cable_state
|
||||
print(f"Cable state after 15 sec pause: {cable_state}")
|
||||
print(f"Capabilities status after 15 sec pause:\n{role.pdcrx.capabilities.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()
|
||||
212
docs/UCD-API文档/examples/work_with_ag_pg.py
Normal file
212
docs/UCD-API文档/examples/work_with_ag_pg.py
Normal file
@@ -0,0 +1,212 @@
|
||||
#
|
||||
# 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_tx = lUniTAP.open("NNNNNNNN")
|
||||
# dev_rx = lUniTAP.open("MMMMMMMM")
|
||||
# dev = lUniTAP.open("NNNNNNNN")
|
||||
|
||||
# dev_tx = lUniTAP.open(0)
|
||||
# dev_rx = lUniTAP.open(1)
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
# role_tx = dev_tx.select_role(UniTAP.dev.UCD323.DPSource)
|
||||
# role_rx = dev_rx.select_role(UniTAP.dev.UCD323.DPSink)
|
||||
roles = dev.select_role(UniTAP.dev.UCD400.DPSourceDPSink)
|
||||
role_tx = roles.dptx
|
||||
role_rx = roles.dprx
|
||||
|
||||
# For HDMI uncomment following lines, and comment previous lines.
|
||||
# role_tx = dev_tx.select_role(UniTAP.dev.UCD323.HDMISource)
|
||||
# role_rx = dev_rx.select_role(UniTAP.dev.UCD323.HDMISink)
|
||||
# roles = dev.select_role(UniTAP.dev.UCD422.HDMISourceHDMISink)
|
||||
# role_tx = roles.hdtx
|
||||
# role_rx = roles.hdrx
|
||||
|
||||
# For configure Pattern Generator, you should call function 'setup' with parameters:
|
||||
# number of stream(for UCD 323 DP TX and HDMI will be 0)
|
||||
# Video mode - describe selected Timing and ColorMode
|
||||
# Timing contain info about all resolutions (like H and V Total, H and V Active and so on), frame rate,
|
||||
# timing standard (CVT, DMT, CTA)
|
||||
# ColorMode contain info about colorimetry, color_format(RGB, YCbCr444, YCbCr422 and so on),
|
||||
# dynamic_range(VESA or CTA) and bits per color (like 8, 10, 12, 16)
|
||||
# content_type - one of the value from enum PGPatternID
|
||||
# content_data - path to image or bytearray of image (if selected PGPatternID.ImageFile)
|
||||
|
||||
|
||||
# For using our predefined device specific timings, you can use 'timing manager' with which you can get them.
|
||||
# Timing manager available in dptx and hdtx roles.
|
||||
|
||||
# timing_manager = role_tx.dptx.pg.timing_manager
|
||||
|
||||
# For HDMI uncomment following lines, and comment previous lines.
|
||||
# timing_manager = role_tx.hdtx.pg.timing_manager
|
||||
|
||||
timing_manager = role_tx.pg.timing_manager
|
||||
|
||||
# timing_manager allow to get full timing information from device. For example method get_cta(id) will return Timing
|
||||
# if there any available CTA timing with VIC=id
|
||||
|
||||
timing = timing_manager.get_cta(16)
|
||||
|
||||
color_mode = UniTAP.ColorInfo()
|
||||
color_mode.color_format = UniTAP.ColorInfo.ColorFormat.CF_RGB
|
||||
color_mode.bpc = 8
|
||||
color_mode.colorimetry = UniTAP.ColorInfo.Colorimetry.CM_sRGB
|
||||
|
||||
video_mode = UniTAP.VideoMode(timing=timing, color_info=color_mode)
|
||||
|
||||
|
||||
#
|
||||
# Start generate video.
|
||||
#
|
||||
|
||||
# If you want to select pattern, you need to use enum 'VideoPattern' from UniTAP.
|
||||
# Like this: UniTAP.VideoPattern.ColorRamp
|
||||
|
||||
# role_tx.dptx.pg.set_vm(vm=video_mode)
|
||||
# role_tx.dptx.pg.set_pattern(pattern=UniTAP.VideoPattern.ColorRamp)
|
||||
# res = role_tx.dptx.pg.apply()
|
||||
|
||||
# For HDMI uncomment following lines, and comment previous lines.
|
||||
|
||||
# role_tx.hdtx.pg.set_vm(vm=video_mode)
|
||||
# role_tx.hdtx.pg.set_pattern(pattern=UniTAP.VideoPattern.ColorRamp)
|
||||
# res = role_tx.hdtx.pg.apply()
|
||||
|
||||
role_tx.pg.set_vm(vm=video_mode)
|
||||
role_tx.pg.set_pattern(pattern=UniTAP.VideoPattern.ColorRamp)
|
||||
res = role_tx.pg.apply()
|
||||
|
||||
if res:
|
||||
print("Pattern generator configure success")
|
||||
|
||||
# HPD Control. For DP Possible to control HPD (assert/deassert) and generate HPD pulse with required length,
|
||||
# for HDMI only HPD (assert/deassert)
|
||||
|
||||
# role_rx.dprx.link.set_assert_state(True)
|
||||
# role_rx.dprx.link.hpd_pulse()
|
||||
|
||||
# For HDMI uncomment following lines, and comment previous lines.
|
||||
|
||||
# role_rx.hdrx.link.status.set_assert_state(True)
|
||||
|
||||
role_rx.link.set_assert_state(True)
|
||||
role_rx.link.hpd_pulse()
|
||||
|
||||
#
|
||||
# Start generate audio
|
||||
#
|
||||
|
||||
# For starting generate audio, need to config audio generator with following parameters:
|
||||
# AudioMode - contain info about sample rate, bits count and channel count
|
||||
# audio pattern - value from enum AudioPattern (like UniTAP.AudioPattern.SignalSine)
|
||||
|
||||
audio_mode = UniTAP.AudioMode()
|
||||
audio_mode.channel_count = 2
|
||||
audio_mode.bits = 16
|
||||
audio_mode.sample_rate = 44100
|
||||
|
||||
# role_tx.dptx.ag.setup(audio_mode=audio_mode, audio_pattern=UniTAP.AudioPattern.SignalSine,
|
||||
# signal_frequency=1000, amplitude=60)
|
||||
# res = role_tx.dptx.ag.apply()
|
||||
|
||||
# For HDMI uncomment following lines, and comment previous lines.
|
||||
|
||||
# role_tx.hdtx.ag.setup(audio_mode=audio_mode, audio_pattern='Sine', signal_frequency=1000, amplitude=60)
|
||||
# res = role_tx.hdtx.ag.apply()
|
||||
|
||||
role_tx.ag.setup(audio_mode=audio_mode, audio_pattern=UniTAP.AudioPattern.SignalSine, signal_frequency=1000, amplitude=60)
|
||||
res = role_tx.ag.apply()
|
||||
|
||||
if res:
|
||||
print("Audio generator configure success")
|
||||
|
||||
# time.sleep(5)
|
||||
# role.dptx.ag.stop_generate()
|
||||
# role.hdtx.ag.stop_generate()
|
||||
|
||||
#
|
||||
# Read current video mode and crc
|
||||
#
|
||||
time.sleep(1)
|
||||
|
||||
# Sometimes RX need some time to start getting video (will be improved in the future versions).
|
||||
|
||||
|
||||
# Get current stream status (VM, CRC, DSC CRC)
|
||||
# stream = role_rx.dprx.link.status.stream(0)
|
||||
# print(stream)
|
||||
|
||||
# For HDMI uncomment following lines, and comment previous lines.
|
||||
|
||||
# stream = role_rx.hdrx.link.status.stream(0)
|
||||
# print(stream)
|
||||
|
||||
stream = role_rx.link.status.stream(0)
|
||||
print(stream)
|
||||
|
||||
#
|
||||
# Check and capture audio
|
||||
#
|
||||
# role_rx.dprx.audio_capturer.start(m_sec=5000)
|
||||
# audio_capture_result = role_rx.dprx.audio_capturer.capture_result
|
||||
|
||||
# For HDMI uncomment following lines, and comment previous lines.
|
||||
|
||||
# role_rx.hdrx.audio_capturer.start(m_sec=5000)
|
||||
# audio_capture_result = role_rx.hdrx.audio_capturer.capture_result
|
||||
|
||||
role_rx.audio_capturer.start(m_sec=5000)
|
||||
audio_capture_result = role_rx.audio_capturer.capture_result
|
||||
|
||||
#
|
||||
# Save captured audio to wav file
|
||||
#
|
||||
print(audio_capture_result.audio_mode.__str__())
|
||||
audio_capture_result.save_to_file(file_format=UniTAP.AudioFileFormat.WAV, path="example")
|
||||
|
||||
#
|
||||
# Run Audio test 'Validate audio signal frequency and glitch-free audio reproduction'
|
||||
#
|
||||
# params = role_rx.dut_tests.default_params_of_group(UniTAP.TestGroupId.AUDIO_TEST)
|
||||
|
||||
group_test = UniTAP.TestGroupId.AUDIO_TEST
|
||||
|
||||
# params = role_rx.dut_tests.get_default_parameters(UniTAP.AudioTestParam)
|
||||
params = roles.dut_tests.get_default_parameters(UniTAP.AudioTestParam)
|
||||
params.sample_rate = 44100
|
||||
params.audio_frequency = 1000
|
||||
params.frequency_tolerance = 1
|
||||
params.save_conditions = 'All'
|
||||
params.storage_folder = "./"
|
||||
|
||||
# role_rx.dut_tests.run(group_test, 3, params)
|
||||
# results = role_rx.dut_tests.get_all_tests_results()
|
||||
|
||||
roles.dut_tests.run(group_test, 3, params)
|
||||
results = roles.dut_tests.get_all_tests_results()
|
||||
|
||||
print(results.all_test_results()[0].test_result)
|
||||
|
||||
#
|
||||
# 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()
|
||||
66
docs/UCD-API文档/examples/work_with_as_and_scrolling_pg.py
Normal file
66
docs/UCD-API文档/examples/work_with_as_and_scrolling_pg.py
Normal file
@@ -0,0 +1,66 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
|
||||
role = dev.select_role(UniTAP.dev.UCD400.DPSourceDPSink)
|
||||
# role = dev.select_role(UniTAP.dev.UCD500.DPSourceDPSink)
|
||||
|
||||
|
||||
timing_manager = role.dptx.pg.timing_manager
|
||||
timings = timing_manager.get_all()
|
||||
|
||||
color_mode = UniTAP.ColorInfo()
|
||||
color_mode.color_format = UniTAP.ColorInfo.ColorFormat.CF_RGB
|
||||
color_mode.bpc = 8
|
||||
color_mode.colorimetry = UniTAP.ColorInfo.Colorimetry.CM_sRGB
|
||||
|
||||
video_mode = UniTAP.VideoMode(timing=timings[0], color_info=color_mode)
|
||||
role.dptx.pg.set_vm(vm=video_mode)
|
||||
role.dptx.pg.set_pattern(pattern=UniTAP.VideoPattern.ColorRamp)
|
||||
|
||||
# I case: configure ConstantASParams
|
||||
role.dptx.pg.set_as_config(as_config=UniTAP.ConstantASParams(lines=20))
|
||||
|
||||
# II case: configure SquareASParams
|
||||
role.dptx.pg.set_as_config(as_config=UniTAP.SquareASParams(min_lanes=0, max_lanes=1000, period_frames=10))
|
||||
|
||||
# III case: configure ZigzagASParams
|
||||
role.dptx.pg.set_as_config(as_config=UniTAP.ZigzagASParams(min_lanes=0, max_lanes=1000, increase_lines=100,
|
||||
decrease_lines=100))
|
||||
|
||||
# IV case: configure FixedASParams
|
||||
role.dptx.pg.set_as_config(as_config=UniTAP.FixedASParams(refresh_rate=60, divide_by_1_001=False, increase_lines=100,
|
||||
decrease_lines=100))
|
||||
|
||||
# Configure Scrolling Pattern Params
|
||||
role.dptx.pg.set_scrolling_params(UniTAP.StepsScrollingParams(horizontally=20, vertically=20, frames=10))
|
||||
|
||||
role.dptx.pg.apply()
|
||||
res_app = role.dptx.pg.status().error
|
||||
print(f"Stream 0 - Apply {res_app.__str__()}")
|
||||
|
||||
print(role.dptx.pg[0].adaptive_sync_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()
|
||||
51
docs/UCD-API文档/examples/work_with_audio_capturer.py
Normal file
51
docs/UCD-API文档/examples/work_with_audio_capturer.py
Normal file
@@ -0,0 +1,51 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
# For UCD-500 available following roles:
|
||||
# UniTAP.dev.UCD500.DPSourceDPSink, USBCSourceUSBCSink, DPSourceUSBCSink and USBCSourceDPSink
|
||||
role = dev.select_role(UniTAP.dev.UCD500.DPSourceDPSink)
|
||||
|
||||
# First variant of capturing = set frame count number
|
||||
role.dprx.audio_capturer.start(frames_count=1)
|
||||
role.dprx.audio_capturer.stop()
|
||||
result = role.dprx.audio_capturer.capture_result
|
||||
|
||||
# Second variant of capturing = set number of millisecond
|
||||
# role.dprx.audio_capturer.start(m_sec=1000)
|
||||
# role.dprx.audio_capturer.stop()
|
||||
# result = role.dprx.audio_capturer.capture_result
|
||||
|
||||
# Third variant of capturing = capturing with user's stop command (without predefined number of frames or second)
|
||||
# role.dprx.audio_capturer.start()
|
||||
# result = role.dprx.audio_capturer.pop_element_as_result_object()
|
||||
# role.dprx.audio_capturer.stop()
|
||||
|
||||
# Save captured frames
|
||||
# file_format - BIN and WAV
|
||||
# path - full path to save the audio
|
||||
result.save_to_file(file_format=UniTAP.AudioFileFormat.WAV,
|
||||
path="audio")
|
||||
|
||||
#
|
||||
# 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()
|
||||
47
docs/UCD-API文档/examples/work_with_buffered_capture.py
Normal file
47
docs/UCD-API文档/examples/work_with_buffered_capture.py
Normal file
@@ -0,0 +1,47 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
role = dev.select_role(UniTAP.dev.UCD500.DPSourceDPSink)
|
||||
rx_port = role.dprx
|
||||
|
||||
# role = dev.select_role(UniTAP.dev.UCD323.HDMISink)
|
||||
# rx_port = role.hdrx
|
||||
|
||||
# First variant of capturing = set frame count number
|
||||
rx_port.video_capturer.start(frames_count=60, capture_type=UniTAP.CaptureConfig.Type.BUFFERED)
|
||||
rx_port.video_capturer.stop()
|
||||
result = rx_port.video_capturer.capture_result
|
||||
|
||||
# Save captured frames
|
||||
# file_format - BIN, PPM and BMP
|
||||
# path - full path to save the image
|
||||
# index - index of captured image
|
||||
|
||||
for i in range(len(result.buffer)):
|
||||
result.save_image_to_file(file_format=UniTAP.PictureFileFormat.BMP,
|
||||
path=f"./results/image_{i}",
|
||||
index=i)
|
||||
|
||||
#
|
||||
# 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()
|
||||
66
docs/UCD-API文档/examples/work_with_bulk_capturer.py
Normal file
66
docs/UCD-API文档/examples/work_with_bulk_capturer.py
Normal file
@@ -0,0 +1,66 @@
|
||||
import UniTAP
|
||||
import time
|
||||
import threading
|
||||
|
||||
|
||||
def link_training(dev_role):
|
||||
time.sleep(1)
|
||||
dev_role.dptx.link.start_link_training()
|
||||
|
||||
|
||||
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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# Need to select type of device: UCD-400 or UCD-500
|
||||
role = dev.select_role(UniTAP.dev.UCD400.DPSourceDPSink)
|
||||
# role = dev.select_role(UniTAP.dev.UCD500.DPSourceDPSink)
|
||||
|
||||
# bulk_size - size of data in megabytes
|
||||
# trigger_position - available position of trigger. Variants: TP_Start, TP_25, TP_50, TP_75, TP_End
|
||||
# trigger_config - one of the variant of active trigger.
|
||||
# assume_scrambler - just flag of assume scrambler
|
||||
|
||||
bulk_size = 100
|
||||
|
||||
# Case without trigger
|
||||
# role.dprx.bulk_capturer.start(bulk_size=bulk_size, trigger_position=UniTAP.bulk.TriggerPosition.TP_Start,
|
||||
# assume_scrambler=False, gpio=False)
|
||||
|
||||
# Case with trigger
|
||||
# In loopback mode we need to use special function for calling 'trigger'.
|
||||
# In current case we need to call 'link training'.
|
||||
thread = threading.Thread(target=link_training, args=(role,))
|
||||
trigger_config = UniTAP.bulk.TriggerType.U13()
|
||||
trigger_config.position = UniTAP.bulk.TriggerTypeEnum.SourceTypePosition.InitialLT
|
||||
|
||||
thread.start()
|
||||
role.dprx.bulk_capturer.start(bulk_size=bulk_size, trigger_position=UniTAP.bulk.TriggerPosition.TP_Start,
|
||||
trigger_config=trigger_config,
|
||||
assume_scrambler=False, gpio=False)
|
||||
role.dprx.bulk_capturer.stop()
|
||||
thread.join()
|
||||
thread.stop_thread = False
|
||||
|
||||
# If you want to get captured data, please, use 'capture_result'. It is the object of class 'ResultBulkObject'.
|
||||
# For saving data in file, please, use 'save_to_bin_file'. You need to set 'directory_name' - name of directory,
|
||||
# where you want to save files. If directory have already existed, is will be clean up.
|
||||
# If directory does not exist, it will be created.
|
||||
result = role.dprx.bulk_capturer.capture_result
|
||||
|
||||
directory_name = "./BulkData"
|
||||
result.save_to_bin_file(directory_name=directory_name)
|
||||
|
||||
#
|
||||
# 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()
|
||||
259
docs/UCD-API文档/examples/work_with_bulk_different_modes.py
Normal file
259
docs/UCD-API文档/examples/work_with_bulk_different_modes.py
Normal file
@@ -0,0 +1,259 @@
|
||||
import os
|
||||
import UniTAP
|
||||
import time
|
||||
import math
|
||||
import threading
|
||||
|
||||
#
|
||||
# Config.
|
||||
#
|
||||
|
||||
BULK_SIZE_MB = 100 # Mb
|
||||
FOLDER_TO_GENERATE = "./BulkData"
|
||||
|
||||
tps3 = True
|
||||
tps4 = True
|
||||
fec = True
|
||||
|
||||
lanes = [
|
||||
1,
|
||||
2,
|
||||
4
|
||||
]
|
||||
|
||||
# If you want to use UCD-400, please, set 'dp_14_mode = True' and 'enable_dp_21_mode = False'
|
||||
# If you want to use UCD-500 in DP 1.4 mode, please, set 'dp_14_mode = True' and 'enable_dp_21_mode = False'
|
||||
# If you want to use UCD-500 in DP 2.1 mode, please, set 'dp_14_mode = False' and 'enable_dp_21_mode = True'
|
||||
dp_14_mode = False
|
||||
bit_rates_14 = [
|
||||
1.62,
|
||||
2.7,
|
||||
5.4,
|
||||
6.75,
|
||||
8.1
|
||||
]
|
||||
|
||||
enable_dp_21_mode = True
|
||||
bit_rates_21 = [
|
||||
10,
|
||||
13.5,
|
||||
20
|
||||
]
|
||||
|
||||
mst = True
|
||||
streams = [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3
|
||||
]
|
||||
|
||||
#
|
||||
# Trigger config.
|
||||
#
|
||||
|
||||
trigger_positions = [
|
||||
UniTAP.bulk.TriggerPosition.TP_Start,
|
||||
UniTAP.bulk.TriggerPosition.TP_25,
|
||||
UniTAP.bulk.TriggerPosition.TP_50,
|
||||
UniTAP.bulk.TriggerPosition.TP_75,
|
||||
UniTAP.bulk.TriggerPosition.TP_End
|
||||
]
|
||||
|
||||
# If you do not want to use trigger config, please, set 'None' to variable
|
||||
# Use other types of trigger config. Full list located in 'TriggerType'
|
||||
trigger_config = UniTAP.bulk.TriggerType.U13()
|
||||
trigger_config.position = UniTAP.bulk.TriggerTypeEnum.SourceTypePosition.InitialLT
|
||||
|
||||
|
||||
lUniTAP = UniTAP.TsiLib()
|
||||
|
||||
#
|
||||
# For opening device, please, put serial number of the device as 8 symbol str or put index of device.
|
||||
#
|
||||
# serial_number = "2150C474"
|
||||
# dev = lUniTAP.open(serial_number)
|
||||
|
||||
# If you do not want to write device serial number, you can write index position of device
|
||||
index_position = 0
|
||||
dev = lUniTAP.open(index_position)
|
||||
|
||||
# Need to select type of device: UCD-400 or UCD-500
|
||||
# role = dev.select_role(UniTAP.dev.UCD400.DPSourceDPSink)
|
||||
role = dev.select_role(UniTAP.dev.UCD500.DPSourceDPSink)
|
||||
|
||||
timing_manager = role.dptx.pg.timing_manager
|
||||
|
||||
timings = [
|
||||
timing_manager.get_cta(16),
|
||||
timing_manager.get_cta(90),
|
||||
timing_manager.get_cta(97),
|
||||
timing_manager.get_cta(126),
|
||||
timing_manager.get_cta(196),
|
||||
]
|
||||
|
||||
color_formats = [
|
||||
UniTAP.ColorInfo.ColorFormat.CF_RGB,
|
||||
UniTAP.ColorInfo.ColorFormat.CF_YCbCr_444,
|
||||
UniTAP.ColorInfo.ColorFormat.CF_YCbCr_422,
|
||||
UniTAP.ColorInfo.ColorFormat.CF_YCbCr_420,
|
||||
UniTAP.ColorInfo.ColorFormat.CF_Y_ONLY,
|
||||
UniTAP.ColorInfo.ColorFormat.CF_RAW
|
||||
]
|
||||
|
||||
colorimetry_list = [
|
||||
UniTAP.ColorInfo.Colorimetry.CM_sRGB,
|
||||
UniTAP.ColorInfo.Colorimetry.CM_ITUR_BT601,
|
||||
UniTAP.ColorInfo.Colorimetry.CM_ITUR_BT709
|
||||
]
|
||||
|
||||
# Note: BPC 7 and 14 will be work only with CF_Y_ONLY and CF_RAW
|
||||
bpc_list = [
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
10,
|
||||
12,
|
||||
14,
|
||||
16
|
||||
]
|
||||
|
||||
|
||||
def link_training(dev_role):
|
||||
time.sleep(1)
|
||||
dev_role.dptx.link.start_link_training()
|
||||
|
||||
|
||||
def bool_str_format(value: bool) -> str:
|
||||
return "ON" if value else "OFF"
|
||||
|
||||
|
||||
def prepare_directory_name(_timing, _color_mode, _lane, _rate, _stream, tr_pos, tr_config=None) -> str:
|
||||
tr_conf_str = type(tr_config).__name__ if tr_config is not None else "-"
|
||||
auto_generated_folder = f"cap_[TG_Pos_{tr_pos.name}][TG_Conf-{tr_conf_str}][{'DP1.4' if dp_14_mode else 'DP2.1'}]" \
|
||||
f"[MST-{bool_str_format(mst)}][FEC-{bool_str_format(fec)}][stream-{_stream}]" \
|
||||
f"[TPS3-{bool_str_format(tps3)}][TPS4-{bool_str_format(tps4)}]" \
|
||||
f"[{_timing.hactive}x{_timing.vactive}@" \
|
||||
f"{math.ceil(_timing.frame_rate / 1000)}_{_color_mode.color_format.name}_{_color_mode.bpc}bpc" \
|
||||
f"-{_color_mode.colorimetry.name}]"
|
||||
directory_name = os.path.join(FOLDER_TO_GENERATE, auto_generated_folder)
|
||||
|
||||
return directory_name
|
||||
|
||||
|
||||
def do_bulk_capture(dev_role, _timing, _color_mode, _lane, _rate, _stream):
|
||||
# bulk_size - size of data in megabytes
|
||||
# trigger_position - available position of trigger. Variants: TP_Start, TP_25, TP_50, TP_75, TP_End
|
||||
# trigger_config - one of the variant of active trigger.
|
||||
# assume_scrambler - just flag of assume scrambler
|
||||
|
||||
for tr_pos in trigger_positions:
|
||||
|
||||
thread = None
|
||||
if trigger_config is not None:
|
||||
thread = threading.Thread(target=link_training, args=(role,))
|
||||
thread.start()
|
||||
|
||||
dev_role.dprx.bulk_capturer.start(bulk_size=BULK_SIZE_MB, trigger_position=tr_pos, trigger_config=trigger_config,
|
||||
assume_scrambler=False, gpio=False)
|
||||
dev_role.dprx.bulk_capturer.stop()
|
||||
|
||||
if trigger_config is not None and thread is not None:
|
||||
thread.join()
|
||||
thread.stop_thread = False
|
||||
|
||||
# If you want to get captured data, please, use 'capture_result'. It is the object of class 'ResultBulkObject'.
|
||||
# For saving data in file, please, use 'save_to_bin_file'. You need to set 'directory_name' - name of directory,
|
||||
# where you want to save files. If directory have already existed, is will be clean up.
|
||||
# If directory does not exist, it will be created.
|
||||
result = dev_role.dprx.bulk_capturer.capture_result
|
||||
|
||||
directory_name = prepare_directory_name(_timing, _color_mode, _lane, _rate, _stream, tr_pos, trigger_config)
|
||||
result.save_to_bin_file(directory_name=directory_name)
|
||||
|
||||
|
||||
for lane in lanes:
|
||||
if dp_14_mode:
|
||||
rates = bit_rates_14
|
||||
else:
|
||||
rates = bit_rates_21
|
||||
for timing in timings:
|
||||
for rate in rates:
|
||||
for stream in streams:
|
||||
for color_format in color_formats:
|
||||
for bpc in bpc_list:
|
||||
for colorimetry in colorimetry_list:
|
||||
|
||||
# Configure Sink Link caps
|
||||
caps = UniTAP.LinkCapabilities()
|
||||
caps.max_lane = lane
|
||||
if dp_14_mode:
|
||||
caps.bit_rate = rate
|
||||
else:
|
||||
caps.dp_128_132_bitrates = [rate]
|
||||
caps.fec = fec
|
||||
caps.tps3 = tps3
|
||||
caps.tps4 = tps4
|
||||
caps.mst = mst
|
||||
role.dprx.link.capabilities.set(caps)
|
||||
role.dprx.link.hpd_pulse()
|
||||
time.sleep(0.5)
|
||||
|
||||
# Configure Source Link
|
||||
if dp_14_mode:
|
||||
config = UniTAP.LinkConfig.DP8b10b()
|
||||
config.mst = mst
|
||||
else:
|
||||
config = UniTAP.LinkConfig.DP128b132b()
|
||||
|
||||
config.lane_count = lane
|
||||
config.bit_rate = rate
|
||||
|
||||
if enable_dp_21_mode:
|
||||
config.force_dp_128_132 = True
|
||||
config.try_dp_128_132 = True
|
||||
else:
|
||||
config.force_dp_128_132 = False
|
||||
config.try_dp_128_132 = False
|
||||
|
||||
role.dptx.link.config.set(config)
|
||||
role.dptx.link.start_link_training()
|
||||
time.sleep(0.5)
|
||||
|
||||
color_mode = UniTAP.ColorInfo()
|
||||
color_mode.color_format = color_format
|
||||
color_mode.bpc = bpc
|
||||
color_mode.colorimetry = colorimetry
|
||||
if color_format in [UniTAP.ColorInfo.ColorFormat.CF_RGB,
|
||||
UniTAP.ColorInfo.ColorFormat.CF_RAW,
|
||||
UniTAP.ColorInfo.ColorFormat.CF_Y_ONLY]:
|
||||
color_mode.dynamic_range = UniTAP.ColorInfo.DynamicRange.DR_VESA
|
||||
else:
|
||||
color_mode.dynamic_range = UniTAP.ColorInfo.DynamicRange.DR_CTA
|
||||
|
||||
video_mode = UniTAP.VideoMode(timing=timing, color_info=color_mode)
|
||||
if stream < role.dptx.pg.max_stream_count:
|
||||
role.dptx.pg[stream].set_vm(vm=video_mode)
|
||||
role.dptx.pg[stream].set_pattern(pattern=UniTAP.VideoPattern.ColorBars)
|
||||
role.dptx.pg[stream].apply()
|
||||
res_app = role.dptx.pg[stream].status().error
|
||||
print(f"Stream {stream} - Apply {res_app.__str__()}")
|
||||
if res_app == res_app.OK:
|
||||
print("Start do bulk capturing")
|
||||
try:
|
||||
do_bulk_capture(role, timing, color_mode, lane, rate, stream)
|
||||
print("Bulk capture completed successfully")
|
||||
except BaseException as e:
|
||||
print(f'Error during bulk capturing. Error: {e}')
|
||||
else:
|
||||
print('Cannot start to do bulk capturing, because PG does not apply settings.')
|
||||
|
||||
#
|
||||
# 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()
|
||||
87
docs/UCD-API文档/examples/work_with_cec.py
Normal file
87
docs/UCD-API文档/examples/work_with_cec.py
Normal file
@@ -0,0 +1,87 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
|
||||
role = dev.select_role(UniTAP.dev.UCD422.HDMISourceHDMISink)
|
||||
|
||||
# Enable CEC
|
||||
role.hdrx.cec.enable(True)
|
||||
|
||||
# Fill command separately
|
||||
# role.hdrx.cec.logical_address = UniTAP.cec.LogicalAddressEnum.Tv
|
||||
# role.hdrx.cec.destination = UniTAP.cec.LogicalAddressEnum.Broadcast
|
||||
# role.hdrx.cec.phy_address = 0x1111
|
||||
# role.hdrx.cec.device_type = UniTAP.cec.DeviceType(cec_switch=True)
|
||||
# role.hdrx.cec.op_code = 0x84
|
||||
# role.hdrx.cec.op_code_param = 0x0
|
||||
#
|
||||
# # Save command as object of class
|
||||
# cec_command = UniTAP.cec.CECCommand()
|
||||
# cec_command.logical_address = UniTAP.cec.LogicalAddressEnum.Tv
|
||||
# cec_command.destination = UniTAP.cec.LogicalAddressEnum.Broadcast
|
||||
# cec_command.phy_address = 0x1111
|
||||
# cec_command.device_type = UniTAP.cec.DeviceType(cec_switch=True)
|
||||
# cec_command.op_code = 0x84
|
||||
# cec_command.op_code_param = 0x0
|
||||
# role.hdrx.cec.add_command(cec_command)
|
||||
#
|
||||
# # Send command by index
|
||||
# role.hdrx.cec.send_command_by_index(0)
|
||||
|
||||
# Send command with parameters
|
||||
# 'device_type' can be value from enum `DeviceTypeEnum` or object of `DeviceType` class
|
||||
role.hdrx.cec.send_command(logical_address=UniTAP.cec.LogicalAddressEnum.Broadcast,
|
||||
destination=UniTAP.cec.LogicalAddressEnum.Tv,
|
||||
phy_address=0x0, op_code=0x0, op_code_param=0x0,
|
||||
device_type=UniTAP.cec.DeviceTypeEnum.TV | UniTAP.cec.DeviceTypeEnum.PlayBack)
|
||||
|
||||
# Send all commands
|
||||
role.hdrx.cec.send_commands()
|
||||
|
||||
# Read CEC Data
|
||||
cec_data = role.hdrx.cec.data
|
||||
print(f'CEC Data:\n{cec_data}')
|
||||
|
||||
# Read CEC buffer status
|
||||
print(role.hdrx.cec.status)
|
||||
|
||||
# Approximately the same procedure on TX side [without parameter `destination`]
|
||||
cec_command = UniTAP.cec.CECCommand()
|
||||
cec_command.logical_address = UniTAP.cec.LogicalAddressEnum.Tv
|
||||
cec_command.phy_address = 0x1111
|
||||
cec_command.device_type = UniTAP.cec.DeviceType(cec_switch=True)
|
||||
cec_command.op_code = 0x84
|
||||
cec_command.op_code_param = 0x0
|
||||
role.hdtx.cec.add_command(cec_command)
|
||||
|
||||
role.hdtx.cec.send_commands()
|
||||
|
||||
role.hdtx.cec.send_command(logical_address=UniTAP.cec.LogicalAddressEnum.Broadcast,
|
||||
phy_address=0x0, op_code=0x0, op_code_param=0x0,
|
||||
device_type=UniTAP.cec.DeviceTypeEnum.TV)
|
||||
|
||||
#
|
||||
# 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()
|
||||
|
||||
55
docs/UCD-API文档/examples/work_with_display_id.py
Normal file
55
docs/UCD-API文档/examples/work_with_display_id.py
Normal file
@@ -0,0 +1,55 @@
|
||||
import time
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
role = dev.select_role(UniTAP.dev.UCD400.DPSourceDPSink)
|
||||
|
||||
# Enable DisplayID on RX side.
|
||||
role.dprx.display_id.enable(True);
|
||||
|
||||
# Will be returned bytearray with DisplayID.
|
||||
# For reading remote DisplayID you should select Virtual channel on TX side and call function
|
||||
# 'read_sbm (index of virtual channel)'
|
||||
|
||||
display_id_data = role.dptx.display_id.read_i2c()
|
||||
print(display_id_data)
|
||||
|
||||
caps = UniTAP.LinkCapabilities()
|
||||
caps.mst = True
|
||||
role.dprx.link.capabilities.set(caps)
|
||||
|
||||
config = role.dptx.link.config.get(UniTAP.LinkConfig.DP8b10b)
|
||||
config.mst = True
|
||||
role.dptx.link.config.set(config)
|
||||
role.dptx.link.start_link_training()
|
||||
time.sleep(5)
|
||||
|
||||
sbm_display_id_data = role.dptx.display_id.read_sbm(0)
|
||||
print(sbm_display_id_data)
|
||||
|
||||
role.dprx.display_id.enable(False);
|
||||
|
||||
#
|
||||
# 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()
|
||||
51
docs/UCD-API文档/examples/work_with_dp_aux_controller.py
Normal file
51
docs/UCD-API文档/examples/work_with_dp_aux_controller.py
Normal file
@@ -0,0 +1,51 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
import time
|
||||
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
|
||||
# role = dev.select_role(UniTAP.dev.UCD400.DPSourceDPSink)
|
||||
role = dev.select_role(UniTAP.dev.UCD323.DPSink)
|
||||
|
||||
print(f"AUX Controller(before), Routed LT status\n{role.dprx.link.aux_controller.status()}")
|
||||
|
||||
routed_lt_config = UniTAP.RoutedLTConfig()
|
||||
routed_lt_config.lane_count = 4
|
||||
routed_lt_config.pe = 1
|
||||
routed_lt_config.vs = 1
|
||||
routed_lt_config.link_bw = 10 # 2.7 Gbps
|
||||
routed_lt_config.is128b132b = False
|
||||
routed_lt_config.is_old_dp20_lt = False
|
||||
routed_lt_config.is_edp_lt = False
|
||||
|
||||
use_ta_request = True
|
||||
|
||||
role.dprx.link.aux_controller.enable(True)
|
||||
role.dprx.link.aux_controller.exec_routed_lt(config=routed_lt_config,
|
||||
use_ta_request=use_ta_request)
|
||||
|
||||
time.sleep(5)
|
||||
print(f"AUX Controller(after), Routed LT status\n{role.dprx.link.aux_controller.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()
|
||||
40
docs/UCD-API文档/examples/work_with_dpcd.py
Normal file
40
docs/UCD-API文档/examples/work_with_dpcd.py
Normal file
@@ -0,0 +1,40 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
|
||||
# role = dev.select_role(UniTAP.dev.UCD400.DPSourceDPSink)
|
||||
role = dev.select_role(UniTAP.dev.UCD500.DPSourceDPSink)
|
||||
|
||||
# Will be returned object of DPCDRegion
|
||||
dpcd_data = role.dptx.dpcd.read(0, 1)
|
||||
|
||||
# Print data of DPCDRegion object
|
||||
print(dpcd_data.data)
|
||||
|
||||
# Write DPCDRegion data to device
|
||||
role.dptx.dpcd.write(0, dpcd_data.data)
|
||||
|
||||
#
|
||||
# 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()
|
||||
44
docs/UCD-API文档/examples/work_with_dsc.py
Normal file
44
docs/UCD-API文档/examples/work_with_dsc.py
Normal file
@@ -0,0 +1,44 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
import UniTAP
|
||||
from UniTAP.utils import encode_video_frame, decode_video_frame, video_frame_save_to_file, ImageFileFormat
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
# For UCD-500 available following roles:
|
||||
# UniTAP.dev.UCD500.DPSourceDPSink, USBCSourceUSBCSink, DPSourceUSBCSink and USBCSourceDPSink
|
||||
role = dev.select_role(UniTAP.dev.UCD400.DPSourceDPSink)
|
||||
|
||||
# First variant of capturing = set frame count number
|
||||
role.dprx.video_capturer.start(stream_number=0)
|
||||
frame = role.dprx.video_capturer.pop_element()
|
||||
role.dprx.video_capturer.stop()
|
||||
|
||||
# Decode DSC Video frame and save
|
||||
image_path = "image.bmp"
|
||||
decoded_vf = decode_video_frame(frame)
|
||||
video_frame_save_to_file(video_frame=decoded_vf, path=image_path, file_type=ImageFileFormat.IFF_BMP)
|
||||
|
||||
# Save raw DSC Video frame
|
||||
image_path = "image.dsc"
|
||||
video_frame_save_to_file(video_frame=frame, path=image_path, file_type=ImageFileFormat.IFF_DSC)
|
||||
|
||||
#
|
||||
# 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()
|
||||
56
docs/UCD-API文档/examples/work_with_earc_tx.py
Normal file
56
docs/UCD-API文档/examples/work_with_earc_tx.py
Normal file
@@ -0,0 +1,56 @@
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
|
||||
role = dev.select_role(UniTAP.dev.UCD323.HDMISinkEARC)
|
||||
role.hdrx.earc.configure(mode=UniTAP.EarcMode.eArc, latency=0)
|
||||
|
||||
print("Starting audio generator...")
|
||||
print("eARC TX Status:", role.hdrx.earc.get_status())
|
||||
role.hdrx.earc.ag.setup(audio_mode=UniTAP.AudioMode(), audio_pattern=UniTAP.AudioPattern.SignalSine)
|
||||
role.hdrx.earc.ag.apply()
|
||||
|
||||
print("Audio generator is running...")
|
||||
print("eARC TX Status:", role.hdrx.earc.get_status())
|
||||
print("AG status:", role.hdrx.earc.ag.status)
|
||||
time.sleep(5)
|
||||
|
||||
print("Starting againg...")
|
||||
print("eARC TX Status:", role.hdrx.earc.get_status())
|
||||
print("AG status:", role.hdrx.earc.ag.status)
|
||||
role.hdrx.earc.ag.apply()
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
print("Stopping audio generator...")
|
||||
print("eARC TX Status:", role.hdrx.earc.get_status())
|
||||
print("AG status:", role.hdrx.earc.ag.status)
|
||||
role.hdrx.earc.ag.stop_generate()
|
||||
|
||||
print("eARC RX EDID:", role.hdrx.earc.get_edid())
|
||||
|
||||
#
|
||||
# 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()
|
||||
34
docs/UCD-API文档/examples/work_with_edid.py
Normal file
34
docs/UCD-API文档/examples/work_with_edid.py
Normal file
@@ -0,0 +1,34 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
|
||||
# role = dev.select_role(UniTAP.dev.UCD323.DPSource)
|
||||
# role = dev.select_role(UniTAP.dev.UCD323.HDMISource)
|
||||
role = dev.select_role(UniTAP.dev.UCD400.DPSourceDPSink)
|
||||
|
||||
timings_from_edid = role.dprx.edid.read_timings()
|
||||
|
||||
#
|
||||
# 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()
|
||||
49
docs/UCD-API文档/examples/work_with_event_capturer.py
Normal file
49
docs/UCD-API文档/examples/work_with_event_capturer.py
Normal file
@@ -0,0 +1,49 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
# role = dev.select_role(UniTAP.dev.UCD400.DPSourceDPSink)
|
||||
role = dev.select_role(UniTAP.dev.UCD500.DPSourceDPSink)
|
||||
dev.opf_handler = UniTAP.OpfHandlerInternal(port_tx=role.dptx, port_rx=role.dprx)
|
||||
|
||||
# For getting object of EventFilter, set type of required filter. If filter type is not supported
|
||||
# will be print list of available types.
|
||||
event_filter = role.dprx.event_capturer.event_filter(UniTAP.EventFilterDpRx)
|
||||
event_filter.config_hpd_events(True)
|
||||
event_filter.config_aux_events(True)
|
||||
event_filter.config_sdp_events(True, UniTAP.EventSDP.CG2)
|
||||
event_filter.config_vb_id_events(True, UniTAP.EventVBID.AnyFieldID)
|
||||
|
||||
# For configuration EventLogger, set object of EventFilter to function 'configure_capturer'
|
||||
role.dprx.event_capturer.configure_capturer(event_filter)
|
||||
role.dprx.link.hpd_pulse()
|
||||
role.dprx.event_capturer.start(sec=1)
|
||||
role.dprx.event_capturer.stop()
|
||||
capture_result = role.dprx.event_capturer.capture_result
|
||||
|
||||
file_name = "./EventData"
|
||||
if len(capture_result.buffer) > 0:
|
||||
capture_result.save_to_file_all_events(file_format=UniTAP.EventFileFormat.HTML, path=file_name)
|
||||
|
||||
#
|
||||
# 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()
|
||||
46
docs/UCD-API文档/examples/work_with_force_link_tx.py
Normal file
46
docs/UCD-API文档/examples/work_with_force_link_tx.py
Normal file
@@ -0,0 +1,46 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
role = dev.select_role(UniTAP.dev.UCD500.DPSourceDPSink)
|
||||
|
||||
# Print current Force status
|
||||
role.dptx.link.set_force_link_mode(UniTAP.DPOutLinkMode.Force128b132b)
|
||||
status = role.dptx.link.force_config.get(UniTAP.LinkConfig.Force128b132b)
|
||||
print(f"Old\n{status}")
|
||||
|
||||
config = UniTAP.LinkConfig.Force128b132b()
|
||||
# Lane count: 1, 2, 4
|
||||
config.lane_count = 2
|
||||
# Bit rate: 10.0, 13.5, 20.0
|
||||
config.bit_rate = 10.0
|
||||
# Normal, Force8b10b, Force128b132b
|
||||
config.pattern = UniTAP.DP128b132bLinkPattern.PRBS9
|
||||
role.dptx.link.force_config.set(config)
|
||||
|
||||
# Check config again
|
||||
status = role.dptx.link.force_config.get(UniTAP.LinkConfig.Force128b132b)
|
||||
print(f"New\n{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()
|
||||
35
docs/UCD-API文档/examples/work_with_fw_version_check.py
Normal file
35
docs/UCD-API文档/examples/work_with_fw_version_check.py
Normal file
@@ -0,0 +1,35 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
role = dev.select_role(UniTAP.dev.UCD500.DPSourceDPSink)
|
||||
|
||||
update_available = role.is_fw_update_available() # Check if there is a firmware update available for the current device.
|
||||
if update_available:
|
||||
update_info = role.get_fw_update_info() # Get information about available firmware update.
|
||||
print(f"Firmware update is available:\n{update_info}")
|
||||
else:
|
||||
print("Firmware is up to date.")
|
||||
|
||||
#
|
||||
# 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()
|
||||
101
docs/UCD-API文档/examples/work_with_hdcp.py
Normal file
101
docs/UCD-API文档/examples/work_with_hdcp.py
Normal file
@@ -0,0 +1,101 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
import time
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
|
||||
role = dev.select_role(UniTAP.dev.UCD400.DPSourceDPSink)
|
||||
# role = dev.select_role(UniTAP.dev.UCD500.DPSourceDPSink)
|
||||
|
||||
# Print HDCP 1.4 and 2.3 statuses
|
||||
# print(role.dptx.hdcp.status.get(UniTAP.HdcpStatus.Status1x))
|
||||
print(role.dptx.hdcp.status.get(UniTAP.HdcpStatus.StatusTx2x))
|
||||
# print(role.dprx.hdcp.status.get(UniTAP.HdcpStatus.Status1x))
|
||||
print(role.dprx.hdcp.status.get(UniTAP.HdcpStatus.StatusRx2x))
|
||||
|
||||
# Set config HDCP 1.4 TX
|
||||
# config = UniTAP.HdcpTxConfig.Config1x()
|
||||
# config.encryption = True
|
||||
# config.authenticate = True
|
||||
# config.keys = UniTAP.HdcpSource1XKeys.Production
|
||||
# role.dptx.hdcp.config.set(config)
|
||||
# time.sleep(2)
|
||||
|
||||
# Set config HDCP 1.4 RX
|
||||
# config = UniTAP.HdcpRxConfig.Config1x()
|
||||
# config.keys = UniTAP.HdcpSink1XKeys.Production
|
||||
# config.capable = True
|
||||
|
||||
# print(role.dptx.hdcp.status.get(UniTAP.HdcpStatus.Status1x))
|
||||
# print(role.dptx.hdcp.status.get(UniTAP.HdcpStatus.StatusTx2x))
|
||||
# print(role.dprx.hdcp.status.get(UniTAP.HdcpStatus.Status1x))
|
||||
# print(role.dprx.hdcp.status.get(UniTAP.HdcpStatus.StatusRx2x))
|
||||
|
||||
# Set config HDCP 2.3
|
||||
config = UniTAP.HdcpTxConfig.Config2x()
|
||||
config.encryption = True
|
||||
config.authenticate = True
|
||||
config.keys = UniTAP.HdcpSource2XKeys.Production
|
||||
config.store_km = True
|
||||
config.content_level = 1
|
||||
role.dptx.hdcp.config.set(config)
|
||||
time.sleep(2)
|
||||
|
||||
# Set config HDCP 2.3 RX
|
||||
config = UniTAP.HdcpRxConfig.Config2x()
|
||||
config.keys = UniTAP.HdcpSink2XKeys.Production
|
||||
config.capable = True
|
||||
|
||||
# print(role.dptx.hdcp.status.get(UniTAP.HdcpStatus.Status1x))
|
||||
print(role.dptx.hdcp.status.get(UniTAP.HdcpStatus.StatusTx2x))
|
||||
# print(role.dprx.hdcp.status.get(UniTAP.HdcpStatus.Status1x))
|
||||
print(role.dprx.hdcp.status.get(UniTAP.HdcpStatus.StatusRx2x))
|
||||
|
||||
# Get config HDCP 1.4
|
||||
# config_14 = role.dptx.hdcp.config.get(UniTAP.HdcpTxConfig.Config1x)
|
||||
|
||||
# Get config HDCP 2.3
|
||||
config_23 = role.dptx.hdcp.config.get(UniTAP.HdcpTxConfig.Config2x)
|
||||
|
||||
|
||||
# For UCD-323 -> UCD-301
|
||||
# role_rx = dev_rx.select_role(UniTAP.dev.UCD301.HDMISink)
|
||||
# role_tx = dev_tx.select_role(UniTAP.dev.UCD323.HDMISource)
|
||||
|
||||
# Print HDCP 1.4 and 2.3 statuses
|
||||
# print(role_rx.hdrx.hdcp.status.get(UniTAP.HdcpStatus.Status1x))
|
||||
# print(role_tx.hdtx.hdcp.status.get(UniTAP.HdcpStatus.Status1x))
|
||||
|
||||
# Set config HDCP 1.4
|
||||
# config = UniTAP.HdcpTxConfig.Config1x()
|
||||
# config.encryption = True
|
||||
# config.authenticate = True
|
||||
# config.keys = UniTAP.HdcpSource1XKeys.Production
|
||||
# role_tx.hdtx.hdcp.config.set(config)
|
||||
# time.sleep(2)
|
||||
|
||||
# print(role_rx.hdrx.hdcp.status.get(UniTAP.HdcpStatus.Status1x))
|
||||
# print(role_tx.hdtx.hdcp.status.get(UniTAP.HdcpStatus.Status1x))
|
||||
|
||||
#
|
||||
# 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()
|
||||
94
docs/UCD-API文档/examples/work_with_link_rx.py
Normal file
94
docs/UCD-API文档/examples/work_with_link_rx.py
Normal file
@@ -0,0 +1,94 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
|
||||
# role = dev.select_role(UniTAP.dev.UCD400.DPSourceDPSink)
|
||||
role = dev.select_role(UniTAP.dev.UCD500.DPSourceDPSink)
|
||||
|
||||
#
|
||||
# Read current Link Status
|
||||
#
|
||||
print(role.dprx.link.status.cable_state)
|
||||
# Read status of lane 0
|
||||
lane_status = role.dprx.link.status.lane(0)
|
||||
print(lane_status)
|
||||
|
||||
# Read status of VCP (stream 0)
|
||||
vcp_table_status = role.dprx.link.status.vcp(0)
|
||||
print(vcp_table_status)
|
||||
|
||||
# Get current stream status (VM, CRC, DSC CRC)
|
||||
stream = role.dprx.link.status.stream(0)
|
||||
print(stream)
|
||||
|
||||
# Also, you can print all status
|
||||
print(role.dprx.link.status)
|
||||
|
||||
# role.dprx.link.hpd_pulse()
|
||||
|
||||
# # Assert/Deassert
|
||||
# print(role.dprx.link.status.hpd_asserted)
|
||||
# role.dprx.link.set_assert_state(False)
|
||||
# print(role.dprx.link.status.hpd_asserted)
|
||||
# role.dprx.link.set_assert_state(True)
|
||||
# print(role.dprx.link.status.hpd_asserted)
|
||||
|
||||
# Scrambler Seed
|
||||
print(role.dprx.link.scrambler_seed)
|
||||
role.dprx.link.scrambler_seed = 0xfffe
|
||||
print(role.dprx.link.scrambler_seed)
|
||||
|
||||
|
||||
caps = UniTAP.LinkCapabilities()
|
||||
caps.max_lane = 4
|
||||
caps.bit_rate = 8.1
|
||||
caps.dp_128_132_bitrates = None
|
||||
caps.override_10g = None
|
||||
caps.force_cable_status_to_plugged = False
|
||||
caps.old_dp_2_0_lt = False
|
||||
caps.dsc = False
|
||||
caps.ss_sbm = False
|
||||
caps.fec = False
|
||||
caps.tps3 = False
|
||||
caps.tps4 = False
|
||||
caps.mst = True
|
||||
|
||||
print(role.dprx.link.capabilities.link_caps_status())
|
||||
role.dprx.link.capabilities.set(caps)
|
||||
print(role.dprx.link.capabilities.link_caps_status())
|
||||
|
||||
print(role.dprx.link.status.stream(0).sdp_crc16)
|
||||
role.dprx.link.status.reset_sdp_crc16_errors()
|
||||
|
||||
#
|
||||
# Get eDP caps
|
||||
#
|
||||
edp_caps = role.dprx.link.capabilities.link_caps_status(UniTAP.LinkEDPCapabilities)
|
||||
print(edp_caps)
|
||||
edp_caps.max_lane = 2
|
||||
edp_caps.eDp_cur_rate = [1.62, 2.16, 2.43]
|
||||
|
||||
#
|
||||
# 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()
|
||||
100
docs/UCD-API文档/examples/work_with_link_tx.py
Normal file
100
docs/UCD-API文档/examples/work_with_link_tx.py
Normal file
@@ -0,0 +1,100 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
|
||||
role = dev.select_role(UniTAP.dev.UCD400.DPSourceDPSink)
|
||||
# role = dev.select_role(UniTAP.dev.UCD500.DPSourceDPSink)
|
||||
|
||||
#
|
||||
# Read current Link Status
|
||||
#
|
||||
|
||||
# Read status of lane 0
|
||||
lane_status = role.dptx.link.status.lane(0)
|
||||
print(lane_status)
|
||||
|
||||
# Read status of VCP (stream 0)
|
||||
vcp_table_status = role.dptx.link.status.vcp(0)
|
||||
print(vcp_table_status)
|
||||
|
||||
# Read current status of link configuration
|
||||
link_config = role.dptx.link.config.get()
|
||||
print(link_config)
|
||||
|
||||
# Get current stream status (VM, CRC, DSC CRC)
|
||||
stream = role.dptx.link.status.stream(0)
|
||||
print(stream)
|
||||
|
||||
# Also, you can print all status
|
||||
print(role.dptx.link.status)
|
||||
|
||||
# Configure Link 8b/10b
|
||||
config = UniTAP.LinkConfig.DP8b10b()
|
||||
|
||||
# Set new lane count and bit rate
|
||||
config.lane_count = 2
|
||||
config.bit_rate = 6.75
|
||||
|
||||
# Configure Link 128b/132b
|
||||
# config = UniTAP.LinkConfig.DP128b132b()
|
||||
|
||||
# Set new lane count and bit rate
|
||||
# config.lane_count = 2
|
||||
# config.bit_rate = 5
|
||||
|
||||
# config.force_dp_128_132 = True
|
||||
# config.try_dp_128_132 = True
|
||||
# config.enhanced_framing_mode = True
|
||||
|
||||
# Enable MST mode and configure mst stream count
|
||||
config.mst = True
|
||||
config.mst_stream_count = 2
|
||||
|
||||
# Enable/Disable Enhanced framing mode
|
||||
config.enhanced_framing_mode = True
|
||||
|
||||
# Configure SSC
|
||||
ssc_config = UniTAP.SSCConfig()
|
||||
ssc_config.enabled = True
|
||||
ssc_config.amplitude = 34
|
||||
ssc_config.frequency = 59000
|
||||
config.ssc = ssc_config
|
||||
|
||||
# Configure Scrambler Seed
|
||||
# If you do not want to setting scrambler seed value, you can activate 'auto seed'
|
||||
# config.auto_seed = True
|
||||
# role.dptx.link.scrambler_seed = 0xFFFF
|
||||
|
||||
role.dptx.link.config.set(config)
|
||||
role.dptx.link.start_link_training()
|
||||
|
||||
edp_conf = role.dptx.link.config.get(UniTAP.LinkConfig.eDP)
|
||||
print(edp_conf)
|
||||
edp_conf.force_edp = True
|
||||
edp_conf.lane_count = 2
|
||||
edp_conf.eDp_cur_rate = 2.43
|
||||
|
||||
#
|
||||
# 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()
|
||||
92
docs/UCD-API文档/examples/work_with_mst_pg.py
Normal file
92
docs/UCD-API文档/examples/work_with_mst_pg.py
Normal file
@@ -0,0 +1,92 @@
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
|
||||
role = dev.select_role(UniTAP.dev.UCD400.DPSourceDPSink)
|
||||
# role = dev.select_role(UniTAP.dev.UCD500.DPSourceDPSink)
|
||||
|
||||
timing_manager = role.dptx.pg.timing_manager
|
||||
|
||||
color_mode = UniTAP.ColorInfo()
|
||||
color_mode.color_format = UniTAP.ColorInfo.ColorFormat.CF_RGB
|
||||
color_mode.bpc = 8
|
||||
color_mode.colorimetry = UniTAP.ColorInfo.Colorimetry.CM_sRGB
|
||||
|
||||
timings = [timing_manager.get_cta(16),
|
||||
timing_manager.get_cta(12),
|
||||
timing_manager.get_cta(1),
|
||||
timing_manager.get_cta(19)]
|
||||
|
||||
# Also, possible to select timing with using functions: 'get_dmt', 'get_cvt', 'get_by_list_index', 'get_all'
|
||||
|
||||
# Print all available timings
|
||||
print(timing_manager.print_all())
|
||||
|
||||
#
|
||||
# If you want to select pattern, you need to use enum 'VideoPattern' from UniTAP.
|
||||
# Like this: UniTAP.VideoPattern.ColorRamp
|
||||
#
|
||||
|
||||
# Iterate for each available streams
|
||||
for i in range(role.dptx.pg.max_stream_count):
|
||||
video_mode = UniTAP.VideoMode(timing=timings[i], color_info=color_mode)
|
||||
role.dptx.pg[i].set_vm(vm=video_mode)
|
||||
role.dptx.pg[i].set_pattern(pattern=UniTAP.VideoPattern.ColorRamp if i == 0 else UniTAP.VideoPattern.SolidGreen)
|
||||
role.dptx.pg[i].apply()
|
||||
res_app = role.dptx.pg[i].status().error
|
||||
print(f"Stream {i} - Apply {res_app.__str__()}")
|
||||
|
||||
#
|
||||
# After configure Pattern Generators, MST should be enabled in link module as well as selected
|
||||
# stream count
|
||||
#
|
||||
|
||||
cfg = role.dptx.link.config.get()
|
||||
cfg.mst = True
|
||||
cfg.mst_stream_count = 4
|
||||
role.dptx.link.config.set(cfg)
|
||||
role.dptx.link.start_link_training()
|
||||
|
||||
cfg = role.dprx.link.capabilities.link_caps_status()
|
||||
cfg.mst = True
|
||||
cfg.dp_128_132_bitrates = None
|
||||
cfg.override_10g = None
|
||||
role.dprx.link.capabilities.set(cfg)
|
||||
role.dprx.link.hpd_pulse()
|
||||
#
|
||||
# Just random sleep, to be sure that Sink get video
|
||||
#
|
||||
time.sleep(2)
|
||||
|
||||
for i in range(role.dptx.pg.max_stream_count):
|
||||
res = role.dprx.link.status.stream(i).video_mode.timing == timings[i]
|
||||
print(f'Stream {i}\n'
|
||||
f'Reference timing: {timings[i]}. '
|
||||
f'Received timing RX: {role.dprx.link.status.stream(i).video_mode.timing}.\n'
|
||||
f'Result: {res}')
|
||||
|
||||
#
|
||||
# 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()
|
||||
44
docs/UCD-API文档/examples/work_with_packet_generation.py
Normal file
44
docs/UCD-API文档/examples/work_with_packet_generation.py
Normal file
@@ -0,0 +1,44 @@
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
|
||||
# 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)
|
||||
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("PATH_TO_PACKET_FILE")
|
||||
|
||||
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()
|
||||
60
docs/UCD-API文档/examples/work_with_panel_replay.py
Normal file
60
docs/UCD-API文档/examples/work_with_panel_replay.py
Normal file
@@ -0,0 +1,60 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
import time
|
||||
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
role = dev.select_role(UniTAP.dev.UCD500.DPSourceDPSink)
|
||||
|
||||
# Select PR'Active mode'
|
||||
role.dptx.pg.panel_replay.active_mode()
|
||||
time.sleep(3)
|
||||
|
||||
# Get current panel replay configuration of PR regions
|
||||
pr_conf = role.dptx.pg.panel_replay.config.get()
|
||||
|
||||
# Set new values for PR Region
|
||||
pr_conf.regions[0].x = 10
|
||||
pr_conf.regions[0].y = 20
|
||||
pr_conf.regions[0].width = 30
|
||||
pr_conf.regions[0].height = 40
|
||||
|
||||
# PanelReplay config
|
||||
pr_conf.flags.mode = UniTAP.PRMode.PR
|
||||
pr_conf.flags.y_granularity = UniTAP.YGranularity.Value_14
|
||||
pr_conf.flags.early_transport = True
|
||||
pr_conf.flags.main_link_remain_on = True
|
||||
pr_conf.flags.hpd_irq_vsc_sdp = True
|
||||
|
||||
# Apply config
|
||||
role.dptx.pg.panel_replay.config.set(pr_conf)
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
# Read status, command and error
|
||||
print(role.dptx.pg.panel_replay.status.status().name)
|
||||
print(role.dptx.pg.panel_replay.status.command().name)
|
||||
print(role.dptx.pg.panel_replay.status.error().name)
|
||||
|
||||
#
|
||||
# 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()
|
||||
42
docs/UCD-API文档/examples/work_with_pdc_capabilities.py
Normal file
42
docs/UCD-API文档/examples/work_with_pdc_capabilities.py
Normal file
@@ -0,0 +1,42 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
role = dev.select_role(UniTAP.dev.UCD424.USBCSourceUSBCSink)
|
||||
# role = dev.select_role(UniTAP.dev.UCD500.USBCSourceUSBCSink)
|
||||
dev.opf_handler = UniTAP.OpfHandlerInternal(port_tx=role.dptx, port_rx=role.dprx)
|
||||
|
||||
# Print current Capabilities status
|
||||
print(role.pdcrx.capabilities.status)
|
||||
|
||||
# Set Initial role for device
|
||||
role.pdcrx.capabilities.set_initial_role(UniTAP.pdc.PdcDeviceRole.DFP)
|
||||
|
||||
# Set cable control pull up value (current)
|
||||
role.pdcrx.capabilities.cc_pull_up(UniTAP.pdc.CCPullUp.Current_3A)
|
||||
|
||||
# Enable PR Swap
|
||||
role.pdcrx.capabilities.enable_pr_swap(False)
|
||||
|
||||
#
|
||||
# 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()
|
||||
45
docs/UCD-API文档/examples/work_with_pdc_controls.py
Normal file
45
docs/UCD-API文档/examples/work_with_pdc_controls.py
Normal file
@@ -0,0 +1,45 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
# role = dev.select_role(UniTAP.dev.UCD424.USBCSourceUSBCSink)
|
||||
role = dev.select_role(UniTAP.dev.UCD500.USBCSourceUSBCSink)
|
||||
dev.opf_handler = UniTAP.OpfHandlerInternal(port_tx=role.dptx, port_rx=role.dprx)
|
||||
|
||||
# Send PR Swap (Also available FR swap, DR swap and Vconn swap)
|
||||
role.pdcrx.controls.send_pr_swap()
|
||||
|
||||
# Do Reconnect
|
||||
role.pdcrx.controls.reconnect()
|
||||
|
||||
# Do Attach(True)/DeAttach(False)
|
||||
role.pdcrx.controls.attach(True)
|
||||
|
||||
# Change cable control orientation
|
||||
role.pdcrx.controls.orientation(UniTAP.pdc.CableControlOrientation.CC2)
|
||||
|
||||
# Capable communication as PD Source (also available for Sink)
|
||||
role.pdcrx.controls.communication_capable_as_pd_source(capable=True)
|
||||
|
||||
#
|
||||
# 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()
|
||||
51
docs/UCD-API文档/examples/work_with_pdc_dpam.py
Normal file
51
docs/UCD-API文档/examples/work_with_pdc_dpam.py
Normal file
@@ -0,0 +1,51 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
# role = dev.select_role(UniTAP.dev.UCD424.USBCSourceUSBCSink)
|
||||
role = dev.select_role(UniTAP.dev.UCD500.USBCSourceUSBCSink)
|
||||
dev.opf_handler = UniTAP.OpfHandlerInternal(port_tx=role.dptx, port_rx=role.dprx)
|
||||
|
||||
# Get and print current DP Alt Mode status
|
||||
print(role.pdcrx.dp_alt_mode.status)
|
||||
|
||||
# Enter to 4 lane (C and E) DP Alt Mode
|
||||
role.pdcrx.dp_alt_mode.enter_4_lane()
|
||||
|
||||
# Enable flag DP to Type-C adapter mode
|
||||
# role.pdcrx.dp_alt_mode.dp_to_type_c_cable_adapter_mode(enable=True)
|
||||
|
||||
# Get and Set UFP Pin Assignment
|
||||
ufp_pin_assignment = role.pdcrx.dp_alt_mode.ufp_caps
|
||||
dfp_caps = role.pdcrx.dp_alt_mode.dfp_caps
|
||||
ufp_pin_assignment.c_4_lanes = True
|
||||
ufp_pin_assignment.d_2_lanes = False
|
||||
role.pdcrx.dp_alt_mode.ufp_caps = ufp_pin_assignment
|
||||
print("UFP:\n", ufp_pin_assignment)
|
||||
print("DFP:\n", dfp_caps)
|
||||
|
||||
# If was selected UCD-500, may use DP 2.1 DPAM
|
||||
# role.pdcrx.dp_alt_mode.enable_dp21(True)
|
||||
|
||||
#
|
||||
# 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()
|
||||
65
docs/UCD-API文档/examples/work_with_pdc_pdo.py
Normal file
65
docs/UCD-API文档/examples/work_with_pdc_pdo.py
Normal file
@@ -0,0 +1,65 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
role = dev.select_role(UniTAP.dev.UCD424.USBCSourceUSBCSink)
|
||||
# role = dev.select_role(UniTAP.dev.UCD500.USBCSourceUSBCSink)
|
||||
dev.opf_handler = UniTAP.OpfHandlerInternal(port_tx=role.dptx, port_rx=role.dprx)
|
||||
|
||||
|
||||
# Get Source PDO from RX side.
|
||||
# If read_from_device = True, PDO will be read directly from device, not from internal buffer
|
||||
source_pdo_list = role.pdcrx.power_source.get_pdo_list(read_from_device=True)
|
||||
|
||||
for item in source_pdo_list:
|
||||
print(item)
|
||||
|
||||
# Get current Power Role
|
||||
power_role = role.pdcrx.capabilities.status.power_role()
|
||||
print(power_role.name)
|
||||
|
||||
if power_role == UniTAP.pdc.PowerRole.Sink:
|
||||
# If needed to change power role, use reconnect
|
||||
role.pdcrx.controls.reconnect()
|
||||
if power_role == UniTAP.pdc.PowerRole.Source:
|
||||
for index, item in enumerate(source_pdo_list):
|
||||
if index > 0:
|
||||
item.interpret_pdo_as_selected_type(UniTAP.pdc.BatteryPdo)
|
||||
role.pdcrx.power_source.set_pdo_list(source_pdo_list)
|
||||
role.pdcrx.power_source.send_pdo()
|
||||
role.pdcrx.controls.reconnect()
|
||||
|
||||
source_pdo_list = role.pdcrx.power_source.get_pdo_list(read_from_device=True)
|
||||
for item in source_pdo_list:
|
||||
print(item)
|
||||
|
||||
# For Sink PDO the same algorythm, but it is also possible to control `Power Contract`
|
||||
role.pdcrx.power_contract_control.pdo_type_priority = UniTAP.pdc.ContractTypePriority.HigherCurrent
|
||||
|
||||
# Control Internal resistance (only for UCD-340)
|
||||
# print(role.pdcrx.power_contract_control.internal_resistance)
|
||||
# role.pdcrx.power_contract_control.internal_resistance = UniTAP.pdc.InternalResistance.Resistance_3_5_Ohm
|
||||
# print(role.pdcrx.power_contract_control.internal_resistance)
|
||||
|
||||
#
|
||||
# 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()
|
||||
64
docs/UCD-API文档/examples/work_with_pdc_pdo_config.py
Normal file
64
docs/UCD-API文档/examples/work_with_pdc_pdo_config.py
Normal file
@@ -0,0 +1,64 @@
|
||||
import UniTAP
|
||||
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
# role = dev.select_role(UniTAP.dev.UCD424.USBCSourceUSBCSink)
|
||||
role = dev.select_role(UniTAP.dev.UCD500.USBCSourceUSBCSink)
|
||||
dev.opf_handler = UniTAP.OpfHandlerInternal(port_tx=role.dptx, port_rx=role.dprx)
|
||||
|
||||
|
||||
# Set initial power role RX side - SINK, TX side - SOURCE
|
||||
role.pdcrx.capabilities.enable_dr_swap(False)
|
||||
role.pdctx.capabilities.enable_dr_swap(False)
|
||||
role.pdcrx.capabilities.set_initial_role(UniTAP.pdc.PdcDeviceRole.UFP)
|
||||
role.pdctx.capabilities.set_initial_role(UniTAP.pdc.PdcDeviceRole.DFP)
|
||||
|
||||
# Get Source PDO from RX side.
|
||||
# If read_from_device = True, PDO will be read directly from device, not from internal buffer
|
||||
source_pdo_list = role.pdctx.power_source.get_pdo_list(read_from_device=True)
|
||||
|
||||
# Print PDO list from Source
|
||||
print("Initial source PDO list:\n")
|
||||
for item in source_pdo_list:
|
||||
print(item)
|
||||
|
||||
# Change Voltage and Max Current on PDO2
|
||||
source_pdo_list[1].pdo_object.voltage(150)
|
||||
source_pdo_list[1].pdo_object.max_current(200)
|
||||
|
||||
# Apply changes
|
||||
role.pdctx.power_source.set_pdo_list(source_pdo_list)
|
||||
role.pdctx.power_source.send_pdo()
|
||||
role.pdctx.controls.reconnect()
|
||||
|
||||
# Check new pdo list
|
||||
source_pdo_list = role.pdctx.power_source.get_pdo_list(read_from_device=True)
|
||||
print("Source PDO list with changed PDO2 voltage and current fields:\n")
|
||||
for item in source_pdo_list:
|
||||
print(item)
|
||||
|
||||
# Disable PDO2
|
||||
source_pdo_list[1].disable_pdo()
|
||||
role.pdctx.power_source.set_pdo_list(source_pdo_list)
|
||||
role.pdctx.power_source.send_pdo()
|
||||
role.pdctx.controls.reconnect()
|
||||
|
||||
# Check new pdo list
|
||||
source_pdo_list = role.pdctx.power_source.get_pdo_list(read_from_device=True)
|
||||
print("Source PDO list with disabled PDO2:\n")
|
||||
for item in source_pdo_list:
|
||||
print(item)
|
||||
|
||||
|
||||
# Configuration Power Contract Control on Sink. Set PDO Type Priority to Prefer higher current
|
||||
role.pdcrx.power_contract_control.pdo_type_priority = UniTAP.pdc.ContractTypePriority.HigherCurrent
|
||||
|
||||
36
docs/UCD-API文档/examples/work_with_pdc_pr_swap.py
Normal file
36
docs/UCD-API文档/examples/work_with_pdc_pr_swap.py
Normal file
@@ -0,0 +1,36 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
import time
|
||||
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev1 = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
# role = dev.select_role(UniTAP.dev.UCD424.USBCSourceUSBCSink)
|
||||
role = dev1.select_role(UniTAP.dev.UCD500.USBCSourceUSBCSink)
|
||||
dev1.opf_handler = UniTAP.OpfHandlerInternal(port_tx=role.dptx, port_rx=role.dprx)
|
||||
|
||||
before_swap = role.pdcrx.capabilities.status.power_role()
|
||||
print("rx role before swap = ", before_swap)
|
||||
|
||||
role.pdcrx.controls.send_pr_swap()
|
||||
role.pdcrx.capabilities.status.power_role()
|
||||
|
||||
|
||||
while role.pdcrx.capabilities.status.power_role() == before_swap:
|
||||
time.sleep(0.1)
|
||||
|
||||
print("rx role after swap = ", role.pdcrx.capabilities.status.power_role())
|
||||
|
||||
|
||||
55
docs/UCD-API文档/examples/work_with_sink_panel_replay.py
Normal file
55
docs/UCD-API文档/examples/work_with_sink_panel_replay.py
Normal file
@@ -0,0 +1,55 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
role = dev.select_role(UniTAP.dev.UCD500.DPSourceDPSink)
|
||||
|
||||
# Get and print Panel Replay status (flags and debug)
|
||||
sink_pr_status = role.dprx.panel_replay.status
|
||||
print(f"Panel Replay status:\nFlags\n{sink_pr_status.flags()}")
|
||||
|
||||
# Get and print Panel Self Refresh status (flags and debug)
|
||||
sink_psr_status = role.dprx.panel_self_refresh.status
|
||||
print(f"Panel Self Refresh status:\nFlags\n{sink_psr_status.flags()}")
|
||||
|
||||
# Get, set and print Panel Replay capabilities
|
||||
flags, x_granularity, y_granularity, granularity = role.dprx.panel_replay.caps.get()
|
||||
print(f"Flags:\n{flags}\n"
|
||||
f"X Granularity - {x_granularity}\n"
|
||||
f"Y Granularity - {y_granularity}\n"
|
||||
f"SU Y granularity\n{granularity}")
|
||||
|
||||
flags.link_off_supported = True
|
||||
flags.early_transport_support = True
|
||||
flags.pr_support = True
|
||||
|
||||
x_granularity = UniTAP.PrGranularityCaps.Line_4
|
||||
y_granularity = UniTAP.PrGranularityCaps.Line_8
|
||||
|
||||
granularity.value_of_14 = True
|
||||
granularity.value_of_20 = True
|
||||
|
||||
role.dprx.panel_replay.caps.set(flags, x_granularity, y_granularity, granularity)
|
||||
|
||||
#
|
||||
# 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()
|
||||
42
docs/UCD-API文档/examples/work_with_solid_color.py
Normal file
42
docs/UCD-API文档/examples/work_with_solid_color.py
Normal file
@@ -0,0 +1,42 @@
|
||||
#
|
||||
# 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) # Open first device
|
||||
dev = lUniTAP.open("NNNNNNNN") # Put your device serial number here
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
role = dev.select_role(UniTAP.dev.UCD323.HDMISource)
|
||||
|
||||
video_mode = role.hdtx.pg.get_stream_video_mode()
|
||||
video_mode.color_info.bpc = 10
|
||||
|
||||
role.hdtx.pg.set_pattern(pattern=UniTAP.VideoPattern.SolidColor)
|
||||
role.hdtx.pg.set_vm(vm=video_mode)
|
||||
role.hdtx.pg.apply()
|
||||
|
||||
for i in range(1024):
|
||||
print(f"Set color: {hex(i)} {hex(i)} {hex(i)}")
|
||||
role.hdtx.pg.set_pattern_params(pattern_params=UniTAP.SolidColorParams(i, i, i))
|
||||
time.sleep(0.01)
|
||||
|
||||
#
|
||||
# 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()
|
||||
76
docs/UCD-API文档/examples/work_with_tests.py
Normal file
76
docs/UCD-API文档/examples/work_with_tests.py
Normal file
@@ -0,0 +1,76 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
role = dev.select_role(UniTAP.dev.UCD400.DPSourceDPSink)
|
||||
# role = dev.select_role(UniTAP.dev.UCD500.DPSourceDPSink)
|
||||
dev.opf_handler = UniTAP.OpfHandlerInternal(port_tx=role.dptx, port_rx=role.dprx)
|
||||
|
||||
group_test = UniTAP.TestGroupId.DP_TX_LL_CTS
|
||||
|
||||
# You can make a copy of the object, configure it and reassign it or can configure it directly
|
||||
|
||||
# Copy
|
||||
params = role.dut_tests.get_default_parameters(UniTAP.Dp14SinkTestParam)
|
||||
|
||||
# Configure supported timings for DP DUT Sink tests
|
||||
params.timings.T_3840_x_2160_60.set_all()
|
||||
params.timings.T_5120_x_2160_60.set_all()
|
||||
|
||||
# Configure Event Filter from Source side
|
||||
event_filter_tx = role.dptx.event_capturer.event_filter(UniTAP.EventFilterDpTx) # Get filter object
|
||||
event_filter_tx.config_hpd_events(True) # Enable capturing HPD events
|
||||
event_filter_tx.config_aux_events(True) # Enable capturing AUX events
|
||||
role.dptx.event_capturer.configure_capturer(event_filter_tx) # Transfer updated filter object
|
||||
|
||||
event_filter_rx = role.dprx.event_capturer.event_filter(UniTAP.EventFilterDpRx) # Get filter object
|
||||
event_filter_rx.config_hpd_events(True) # Enable capturing HPD events
|
||||
event_filter_rx.config_aux_events(True) # Enable capturing AUX events
|
||||
event_filter_rx.config_sdp_events(True, UniTAP.EventSDP.CG2) # Enable capturing SDP (CG2) events
|
||||
role.dprx.event_capturer.configure_capturer(event_filter_rx) # Transfer updated filter object
|
||||
|
||||
role.dptx.event_capturer.start() # Start event capturing
|
||||
|
||||
role.dut_tests.run(group_id=group_test, test_id=0, params=params) # Run selected test
|
||||
|
||||
results = role.dut_tests.get_all_tests_results() # Get results after testing
|
||||
|
||||
role.dptx.event_capturer.stop() # Stop event capturing
|
||||
|
||||
capture_result = role.dptx.event_capturer.pop_all_elements_as_result_object() # Get all captured events
|
||||
|
||||
event_log_file_path = "EventData"
|
||||
event_log_html_file_path = "EventDataReport"
|
||||
if len(capture_result.buffer) > 0:
|
||||
# Save captured events to BIN file and save HTML report
|
||||
capture_result.save_to_file_all_events(file_format=UniTAP.EventFileFormat.BIN, path=event_log_file_path)
|
||||
capture_result.save_to_file_all_events(file_format=UniTAP.EventFileFormat.HTML, path=event_log_html_file_path)
|
||||
else:
|
||||
print("Buffer is empty.")
|
||||
|
||||
# Save test result to HTML report
|
||||
role.dut_tests.make_report('./report',
|
||||
tested_by="Example",
|
||||
remarks="Remarks for test report.")
|
||||
#
|
||||
# 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()
|
||||
44
docs/UCD-API文档/examples/work_with_tests_from_file.py
Normal file
44
docs/UCD-API文档/examples/work_with_tests_from_file.py
Normal file
@@ -0,0 +1,44 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
role = dev.select_role(UniTAP.dev.UCD400.DPSourceDPSink)
|
||||
# role = dev.select_role(UniTAP.dev.UCD500.DPSourceDPSink)
|
||||
dev.opf_handler = UniTAP.OpfHandlerInternal(port_tx=role.dptx, port_rx=role.dprx)
|
||||
|
||||
file_name = "./config.json"
|
||||
group_id, test_id, params = role.dut_tests.get_params_from_file(file_name)
|
||||
|
||||
role.dut_tests.run(group_id=group_id, test_id=test_id, params=params) # Run selected test
|
||||
|
||||
results = role.dut_tests.get_all_tests_results() # Get results after testing
|
||||
|
||||
role.dptx.event_capturer.stop() # Stop event capturing
|
||||
|
||||
# Save test result to HTML report
|
||||
role.dut_tests.make_report('./report',
|
||||
tested_by="Example",
|
||||
remarks="Remarks for test report.")
|
||||
|
||||
#
|
||||
# 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()
|
||||
52
docs/UCD-API文档/examples/work_with_video_capturer.py
Normal file
52
docs/UCD-API文档/examples/work_with_video_capturer.py
Normal file
@@ -0,0 +1,52 @@
|
||||
#
|
||||
# Import UniTAP module.
|
||||
#
|
||||
import UniTAP
|
||||
|
||||
#
|
||||
# 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("NNNNNNNN")
|
||||
dev = lUniTAP.open(0)
|
||||
|
||||
# After opening device as in UCD Console device role should be selected.
|
||||
# For UCD-500 available following roles:
|
||||
# UniTAP.dev.UCD500.DPSourceDPSink, USBCSourceUSBCSink, DPSourceUSBCSink and USBCSourceDPSink
|
||||
role = dev.select_role(UniTAP.dev.UCD500.DPSourceDPSink)
|
||||
|
||||
# First variant of capturing = set frame count number
|
||||
role.dprx.video_capturer.start(frames_count=1, stream_number=1)
|
||||
role.dprx.video_capturer.stop()
|
||||
result = role.dprx.video_capturer.capture_result
|
||||
|
||||
# Second variant of capturing = set number of second
|
||||
# role.dprx.video_capturer.start(sec=1)
|
||||
# role.dprx.video_capturer.stop()
|
||||
# result = role.dprx.video_capturer.capture_result
|
||||
|
||||
# Third variant of capturing = capturing with user's stop command (without predefined number of frames or second)
|
||||
# role.dprx.video_capturer.start()
|
||||
# result = role.dprx.video_capturer.pop_element_as_result_object()
|
||||
# role.dprx.video_capturer.stop()
|
||||
|
||||
# Save captured frames
|
||||
# file_format - BIN, PPM and BMP
|
||||
# path - full path to save the image
|
||||
# index - index of captured image
|
||||
result.save_image_to_file(file_format=UniTAP.PictureFileFormat.BMP,
|
||||
path="image.bmp",
|
||||
index=0)
|
||||
#
|
||||
# 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()
|
||||
Reference in New Issue
Block a user