1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #!/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_ERR_NO_DEVICE = 0x20000001
- UUIRTDRV_ERR_NO_RESP = 0x20000002
- UUIRTDRV_ERR_NO_DLL = 0x20000003
- UUIRTDRV_ERR_VERSION = 0x20000004
- 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
- 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__':
- uuirtdrv = ctypes.WinDLL('uuirtdrv', use_last_error = True)
- handle = uuirtdrv.UUIRTOpen()
- print handle
- print uuirtdrv.UUIRTTransmitIR(handle, '''
- 0000 006E 0022 0002 0155 00AA 0015 0016 0015 0016 0015 0040 0015 0016
- 0015 0016 0015 0016 0015 0016 0015 0016 0015 0040 0015 0040 0015 0016
- 0015 0040 0015 0040 0015 0040 0015 0040 0015 0040 0015 0040 0015 0040
- 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016
- 0015 0016 0015 0040 0015 0040 0015 0040 0015 0040 0015 0040 0015 0040
- 0015 05EC 0155 0055 0015 0E34
- ''', UUIRTDRV_IRFMT_PRONTO, 1, 0, None, None, None)
- uuirtdrv.UUIRTClose(handle)
|