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

49 lines
1.8 KiB
Python
Raw Permalink Normal View History

2026-07-02 17:16:18 +08:00
#
# 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()