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