usbuirt.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_ERR_NO_DEVICE = 0x20000001
  23. UUIRTDRV_ERR_NO_RESP = 0x20000002
  24. UUIRTDRV_ERR_NO_DLL = 0x20000003
  25. UUIRTDRV_ERR_VERSION = 0x20000004
  26. UUIRTDRV_CFG_LEDRX = 0x0001
  27. UUIRTDRV_CFG_LEDTX = 0x0002
  28. UUIRTDRV_CFG_LEGACYRX = 0x0004
  29. UUIRTDRV_IRFMT_UUIRT = 0x0000
  30. UUIRTDRV_IRFMT_PRONTO = 0x0010
  31. UUIRTDRV_IRFMT_LEARN_FORCERAW = 0x0100
  32. UUIRTDRV_IRFMT_LEARN_FORCESTRUC = 0x0200
  33. UUIRTDRV_IRFMT_LEARN_FORCEFREQ = 0x0400
  34. UUIRTDRV_IRFMT_LEARN_FREQDETECT = 0x0800
  35. class UUINFO(ctypes.Structure):
  36. _fields_ = [
  37. ('fwVersion', ctypes.c_uint),
  38. ('protVersion', ctypes.c_uint),
  39. ('fwDateDay', ctypes.c_ubyte),
  40. ('fwDateMonth', ctypes.c_ubyte),
  41. ('fwDateYear', ctypes.c_ubyte),
  42. ]
  43. if __name__ == '__main__':
  44. uuirtdrv = ctypes.WinDLL('uuirtdrv', use_last_error = True)
  45. handle = uuirtdrv.UUIRTOpen()
  46. print handle
  47. print uuirtdrv.UUIRTTransmitIR(handle, '''
  48. 0000 006E 0022 0002 0155 00AA 0015 0016 0015 0016 0015 0040 0015 0016
  49. 0015 0016 0015 0016 0015 0016 0015 0016 0015 0040 0015 0040 0015 0016
  50. 0015 0040 0015 0040 0015 0040 0015 0040 0015 0040 0015 0040 0015 0040
  51. 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016
  52. 0015 0016 0015 0040 0015 0040 0015 0040 0015 0040 0015 0040 0015 0040
  53. 0015 05EC 0155 0055 0015 0E34
  54. ''', UUIRTDRV_IRFMT_PRONTO, 1, 0, None, None, None)
  55. uuirtdrv.UUIRTClose(handle)