usbuirt.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/usr/bin/env python
  2. # DT Home
  3. # USB UIRT
  4. #
  5. # Douglas Thrift
  6. #
  7. # usbuirt.py
  8. # Copyright 2012 Douglas Thrift
  9. #
  10. # Licensed under the Apache License, Version 2.0 (the "License");
  11. # you may not use this file except in compliance with the License.
  12. # You may obtain a copy of the License at
  13. #
  14. # http://www.apache.org/licenses/LICENSE-2.0
  15. #
  16. # Unless required by applicable law or agreed to in writing, software
  17. # distributed under the License is distributed on an "AS IS" BASIS,
  18. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. # See the License for the specific language governing permissions and
  20. # limitations under the License.
  21. import ctypes
  22. UUIRTDRV_OPENEX_ATTRIBUTE_EXCLUSIVE = 0x0001
  23. UUIRTDRV_ERR_NO_DEVICE = 0x20000001
  24. UUIRTDRV_ERR_NO_RESP = 0x20000002
  25. UUIRTDRV_ERR_NO_DLL = 0x20000003
  26. UUIRTDRV_ERR_VERSION = 0x20000004
  27. UUIRTDRV_ERR_ERR_IN_USE = 0x20000005
  28. UUIRTDRV_CFG_LEDRX = 0x0001
  29. UUIRTDRV_CFG_LEDTX = 0x0002
  30. UUIRTDRV_CFG_LEGACYRX = 0x0004
  31. UUIRTDRV_IRFMT_UUIRT = 0x0000
  32. UUIRTDRV_IRFMT_PRONTO = 0x0010
  33. UUIRTDRV_IRFMT_LEARN_FORCERAW = 0x0100
  34. UUIRTDRV_IRFMT_LEARN_FORCESTRUC = 0x0200
  35. UUIRTDRV_IRFMT_LEARN_FORCEFREQ = 0x0400
  36. UUIRTDRV_IRFMT_LEARN_FREQDETECT = 0x0800
  37. UUIRTDRV_IRFMT_LEARN_UIR = 0x4000
  38. UUIRTDRV_IRFMT_LEARN_DEBUG = 0x8000
  39. UUIRTDRV_IRFMT_TRANSMIT_DC = 0x0080
  40. class UUINFO(ctypes.Structure):
  41. _fields_ = [
  42. ('fwVersion', ctypes.c_uint),
  43. ('protVersion', ctypes.c_uint),
  44. ('fwDateDay', ctypes.c_ubyte),
  45. ('fwDateMonth', ctypes.c_ubyte),
  46. ('fwDateYear', ctypes.c_ubyte),
  47. ]
  48. if __name__ == '__main__':
  49. import sys
  50. uuirtdrv = ctypes.WinDLL('uuirtdrv', use_last_error = True)
  51. handle = uuirtdrv.UUIRTOpenEx("USB-UIRT", 0, None, None)
  52. uuirtdrv.UUIRTTransmitIR(handle, ' '.join(sys.argv[1:]), UUIRTDRV_IRFMT_PRONTO, 1, 0, None, None, None)
  53. uuirtdrv.UUIRTClose(handle)