# # 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.UCD422.HDMISourceHDMISink) # Enable CEC role.hdrx.cec.enable(True) # Fill command separately # role.hdrx.cec.logical_address = UniTAP.cec.LogicalAddressEnum.Tv # role.hdrx.cec.destination = UniTAP.cec.LogicalAddressEnum.Broadcast # role.hdrx.cec.phy_address = 0x1111 # role.hdrx.cec.device_type = UniTAP.cec.DeviceType(cec_switch=True) # role.hdrx.cec.op_code = 0x84 # role.hdrx.cec.op_code_param = 0x0 # # # Save command as object of class # cec_command = UniTAP.cec.CECCommand() # cec_command.logical_address = UniTAP.cec.LogicalAddressEnum.Tv # cec_command.destination = UniTAP.cec.LogicalAddressEnum.Broadcast # cec_command.phy_address = 0x1111 # cec_command.device_type = UniTAP.cec.DeviceType(cec_switch=True) # cec_command.op_code = 0x84 # cec_command.op_code_param = 0x0 # role.hdrx.cec.add_command(cec_command) # # # Send command by index # role.hdrx.cec.send_command_by_index(0) # Send command with parameters # 'device_type' can be value from enum `DeviceTypeEnum` or object of `DeviceType` class role.hdrx.cec.send_command(logical_address=UniTAP.cec.LogicalAddressEnum.Broadcast, destination=UniTAP.cec.LogicalAddressEnum.Tv, phy_address=0x0, op_code=0x0, op_code_param=0x0, device_type=UniTAP.cec.DeviceTypeEnum.TV | UniTAP.cec.DeviceTypeEnum.PlayBack) # Send all commands role.hdrx.cec.send_commands() # Read CEC Data cec_data = role.hdrx.cec.data print(f'CEC Data:\n{cec_data}') # Read CEC buffer status print(role.hdrx.cec.status) # Approximately the same procedure on TX side [without parameter `destination`] cec_command = UniTAP.cec.CECCommand() cec_command.logical_address = UniTAP.cec.LogicalAddressEnum.Tv cec_command.phy_address = 0x1111 cec_command.device_type = UniTAP.cec.DeviceType(cec_switch=True) cec_command.op_code = 0x84 cec_command.op_code_param = 0x0 role.hdtx.cec.add_command(cec_command) role.hdtx.cec.send_commands() role.hdtx.cec.send_command(logical_address=UniTAP.cec.LogicalAddressEnum.Broadcast, phy_address=0x0, op_code=0x0, op_code_param=0x0, device_type=UniTAP.cec.DeviceTypeEnum.TV) # # 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()