# # 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()