更新UCD-API库及文档
This commit is contained in:
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()
|
||||
Reference in New Issue
Block a user