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