#!/usr/bin/env python # DT Home # USB UIRT # # Douglas Thrift # # usbuirt.py # Copyright 2012 Douglas Thrift # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import ctypes UUIRTDRV_OPENEX_ATTRIBUTE_EXCLUSIVE = 0x0001 UUIRTDRV_ERR_NO_DEVICE = 0x20000001 UUIRTDRV_ERR_NO_RESP = 0x20000002 UUIRTDRV_ERR_NO_DLL = 0x20000003 UUIRTDRV_ERR_VERSION = 0x20000004 UUIRTDRV_ERR_ERR_IN_USE = 0x20000005 UUIRTDRV_CFG_LEDRX = 0x0001 UUIRTDRV_CFG_LEDTX = 0x0002 UUIRTDRV_CFG_LEGACYRX = 0x0004 UUIRTDRV_IRFMT_UUIRT = 0x0000 UUIRTDRV_IRFMT_PRONTO = 0x0010 UUIRTDRV_IRFMT_LEARN_FORCERAW = 0x0100 UUIRTDRV_IRFMT_LEARN_FORCESTRUC = 0x0200 UUIRTDRV_IRFMT_LEARN_FORCEFREQ = 0x0400 UUIRTDRV_IRFMT_LEARN_FREQDETECT = 0x0800 UUIRTDRV_IRFMT_LEARN_UIR = 0x4000 UUIRTDRV_IRFMT_LEARN_DEBUG = 0x8000 UUIRTDRV_IRFMT_TRANSMIT_DC = 0x0080 class UUINFO(ctypes.Structure): _fields_ = [ ('fwVersion', ctypes.c_uint), ('protVersion', ctypes.c_uint), ('fwDateDay', ctypes.c_ubyte), ('fwDateMonth', ctypes.c_ubyte), ('fwDateYear', ctypes.c_ubyte), ] if __name__ == '__main__': import sys uuirtdrv = ctypes.WinDLL('uuirtdrv', use_last_error = True) handle = uuirtdrv.UUIRTOpenEx("USB-UIRT", 0, None, None) uuirtdrv.UUIRTTransmitIR(handle, ' '.join(sys.argv[1:]), UUIRTDRV_IRFMT_PRONTO, 1, 0, None, None, None) uuirtdrv.UUIRTClose(handle)