 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
robcheese
Joined: 07 Jul 2008 Posts: 27
|
Posted: Wed Apr 15, 2009 11:24 pm Post subject: USB IR Transceiver |
|
|
I am interested in getting an IR transceiver but I don't have the capabilities of making one myself so I was wondering if anyone could suggest a small USB transceiver.
I've got my eye on one made by IguanaWorks but it says it is only compatible with Linux.
http://iguanaworks.net/products.psp
Is this actually the case or are they just not considering winLIRC.
Thanks
[Moved from Ask for Help forum. ~jaco0646] |
|
| Back to top |
|
 |
robcheese
Joined: 07 Jul 2008 Posts: 27
|
Posted: Mon Apr 20, 2009 6:45 pm Post subject: |
|
|
| I just heard back form the IguanaWorks and they say their USB Transceiver is not compatible with winLIRC so can anyone suggest one that is? |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4710 Location: Boulder, CO
|
Posted: Tue Apr 21, 2009 1:19 am Post subject: |
|
|
| USB-UIRT |
|
| Back to top |
|
 |
cynopsys
Joined: 27 Nov 2009 Posts: 43
|
Posted: Wed Jan 06, 2010 1:49 am Post subject: |
|
|
| There's anyway to integrate usb uirt directly in AutoHotKey? |
|
| Back to top |
|
 |
C++ Guest
|
Posted: Wed Jan 06, 2010 7:54 am Post subject: |
|
|
| Quote: | | There's anyway to integrate usb uirt directly in AutoHotKey? | AHK is Open Source. Just do it! |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 4511 Location: Belgrade
|
Posted: Wed Jan 06, 2010 11:58 am Post subject: |
|
|
Is it achievable to use AHK for automation ? _________________
 |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4710 Location: Boulder, CO
|
Posted: Wed Jan 06, 2010 6:16 pm Post subject: |
|
|
| majkinetor wrote: | | Is [USB-UIRT] achievable to use AHK for automation ? | Yes. It has a dll for control functions, which are easily accessible from AHK. |
|
| Back to top |
|
 |
cynopsys
Joined: 27 Nov 2009 Posts: 43
|
Posted: Wed Jan 06, 2010 8:01 pm Post subject: |
|
|
There's anyway to get a woking exemple how to integrate usb uirt.
I'm not very good with dll call and all that kind of thing
If you could guide me It's will help me
please
thanks! |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4710 Location: Boulder, CO
|
Posted: Fri Jan 08, 2010 1:06 am Post subject: |
|
|
I have no time for this now, but a few months ago I checked a few funtion calls. Maybe you will find something useful in this: | Code: | #SingleInstance Force
#NoEnv
SetBatchLines -1
SetWinDelay -1
DllCall("LoadLibrary", Str,"c:\t\USB-UIRT\uuirtdrv.dll")
hndl := DllCall("uuirtdrv.dll\UUIRTOpen") ; open communication to UIRT
VarSetCapacity(IRcode, 2048)
abort = 0
DllCall("uuirtdrv.dll\UUIRTLearnIR", UInt,hndl
, Int, 0x100 ; codeFormat: UUIRTDRV_IRFMT_LEARN_FORCERAW
, Str, IRCode ; the received code
, UInt,CBfunc ; PLEARNCALLBACKPROC progressProc
, Str, "Userdata" ; *userData: passed by the USB-UIRT driver to progressProc calls
, UIntP, abort ; *pAbort set to 1 in another thread: requests abort
, UInt, 0 ; param1 = forced frequency
, UInt,0, UInt,0) ; reserved
Msgbox %IRCode%
MsgBox [%res%]`n[%ErrorLevel%]
DllCall("uuirtdrv.dll\UUIRTClose", UInt,hndl)
/*
DllCall("uuirtdrv.dll\UUIRTGetDrvInfo", UIntP,vers) ; driver vers = 256
VarSetCapacity(uInfo,12)
DllCall("uuirtdrv.dll\UUIRTGetUUIRTInfo", UInt, hndl, UInt, &uInfo)
MsgBox % "fwVersion: " NumGet(uInfo,0) "`nProtocolVersion: " NumGet(uInfo,4)
. "`nFW D/M/Y :" NumGet(uInfo,8,"UChar") "/" NumGet(uInfo,9,"UChar") "/" NumGet(uInfo,10,"UChar")
; Set non-volatile config flag: LED blinks @ signal receive + lights @ IR send
DllCall("uuirtdrv.dll\UUIRTSetUUIRTConfig", UInt,hHandle, UInt,3)
DllCall("uuirtdrv.dll\UUIRTTransmitIR", UInt,hndl, Str,"123456" ; Code to be sent
, Int, 0x10 ; Codeformat (UUIRT: 0, PRONTO: 0x0010)
, Int, 1 ; repeatCount
, Int, 0 ; inactivityWaitTime ms
, Int, 0 ; HANDLE hEvent to signal code sent
, UInt,0, UInt,0)
MsgBox [%res%]`n[%ErrorLevel%]
*/
/* USB-UIRT API: uuirtdrv.dll (www.usbuirt.com/api_example_code.zip)
c:\t\USB-UIRT\uuirtdrv.dll
UUIRTDRV_API HUUHANDLE PASCAL UUIRTOpen(void);
Opens communication with the USB-UIRT. On success, returns a handle to be
used in subsequent calls to USB-UIRT functions. On failure, returns
INVALID_HANDLE_VALUE. A call to UUIRTOpen should occur prior to any other
driver function calls (with the exception of UUIRTGetDrvInfo below).
UUIRTDRV_API BOOL PASCAL UUIRTClose(HUUHANDLE hHandle);
Terminates communication with the USB-UIRT. Should be called prior to
terminating host program.
UUIRTDRV_API BOOL PASCAL UUIRTGetDrvInfo(unsigned int *puDrvVersion);
Retrieves information about the *driver* (not the hardware itself). This is
intended to allow version control on the .DLL driver and accomodate future
changes and enhancements to the API. Returns TRUE on success, as well as a
driver version number in *puDrvVersion. NOTE: This call may be called prior
to a call to UUIRTOpen.
UUIRTDRV_API BOOL PASCAL UUIRTGetUUIRTInfo(HUUHANDLE hHandle, PUUINFO *puuInfo);
Retrieves information about the UUIRT hardware. On success, returns TRUE and
fills in the structure PUUINFO, defined as follows:
typedef struct {
unsigned int fwVersion; // version of firmware residing on the USB-UIRT.
unsigned int protVersion; // protocol version supported by the USB-UIRT firmware.
unsigned char fwDateDay; // firmware revision date
unsigned char fwDateMonth;//
unsigned char fwDateYear; //
} UUINFO, *PUUINFO;
UUIRTDRV_API BOOL PASCAL UUIRTGetUUIRTConfig(HUUHANDLE hHandle, PUINT32 puConfig);
Retrieves the current feature configuration bits from the USB-UIRT's
nonvolatile configuration memory. These various configuration bits control
how the USB-UIRT behaves. Most are reserved for future implementation and
shout be read and written as Zero. Using this API call is optional and is
only needed to support changing USB-UIRT's internal 'preferences'. Bits
defined in uConfig are as follows:
#define UUIRTDRV_CFG_LEDRX 0x01 // Indicator LED on USB-UIRT blinks when remote signals are received
#define UUIRTDRV_CFG_LEDTX 0x02 // Indicator LED on USB-UIRT lights during IR transmission.
#define UUIRTDRV_CFG_LEGACYRX 0x04 // Generate 'legacy' UIRT-compatible codes on receive
#define RESERVED0 0x08
#define RESERVED1 0x10
...
UUIRTDRV_API BOOL PASCAL UUIRTSetUUIRTConfig(HUUHANDLE hHandle, UINT32 uConfig);
Configures the current feature configuration bits for the USB-UIRT's
nonvolatile configuration memory. These various configuration bits control
how the USB-UIRT behaves. See definition of uConfig in UUIRGetUUIRTConfig
above
UUIRTDRV_API BOOL PASCAL UUIRTTransmitIR(HUUHANDLE hHandle, char *IRCode,
int codeFormat, int repeatCount, int inactivityWaitTime, HANDLE hEvent, void
*reserved0, void *reserved1);
Transmits an IR code via the USB-UIRT hardware. The IR code is a
null-terminated *string*. codeFormat is a format specifier which identifies
the format of the IRCode code. Currently, supported formats are
Compressed_UIRT (STRUCT), RAW, and Pronto-RAW. RepeatCount indicates how
many iterations of the code should be sent (in the case of a 2-piece code,
the first stream is sent once followed by the second stream sent repeatCount
times). InactivityWaitTime is the time in milliseconds since the last
received IR activity to wait before sending an IR code -- normally pass 0
for this parameter. hEvent is an optional event handle which is obtained by
a call to CreateEvent. If hEvent is NULL, the call to UUIRTTransmitIR will
block and not return until the IR code has been fully transmitted to the
air. If hEvent is not NULL, it must be a valid Windows event hande. In this
case, UUIRTTransmitIR will return immediately and when the IR stream has
completed transmission this event will be signalled by the driver. The last
parameters, labelled 'reservedx' are for future expansion and should be
NULL.
UUIRTDRV_API BOOL PASCAL UUIRTLearnIR(HUUHANDLE hHandle, int codeFormat,
char *IRCode, PLEARNCALLBACKPROC progressProc, void *userData, BOOL *pAbort,
unsigned int param1, void *reserved0, void *reserved1);
Instructs the USB-UIRT and the API to learn an IR code. The IR code learned
will be a complete IR stream suitable for subsequent transmission via
UUIRTTransmitIR. Consequently, the same formats supported by Transmit are
also available for learn. It is recommended to use either RAW or Pronto-RAW
codeFormat to offer the best compatibility; compressed-UIRT format is often
too limiting, although it does produce the smallest codes. IRCode will be
filled with the learned IR code upon return -- it is the responsibility of
the caller to allocate space for this string -- suggested string size is at
least 2048 bytes. ProgressProc is a caller-supplied callback function which
will be called periodically during the learn process and may be used to
update user dialogs, etc. Information passed to the callback are learn
progress %, signal quality, and carrier frequency. The parameter userData
will be passed by the USB-UIRT driver to any calls of progressProc. The
pAbort parameter should pass the pointer to a Boolean variable which should
be initialized to FALSE (0) prior to the call. Setting this variable TRUE
during the learn process will cause the UUIRTLearnIR process to abort and
the function to return. Since the UUIRTLearnIR function will block for the
duration of the learn process, one could set the *pAbort to TRUE either
within the callback function or from another thread. Param1 is currently
used only when the codeFormat includes the UUIRTDRV_IRFMT_LEARN_FORCEFREQ
flag (not normally needed) -- in which case param1 should indicate the
forced carrier frequency. The last parameters, labelled 'reservedx' are for
future expansion and should be NULL.
UUIRTDRV_API BOOL PASCAL UUIRTSetReceiveCallback(HUUHANDLE hHandle,
PUUCALLBACKPROC receiveProc, void *userData);
Registers a receive callback function which the driver will call when an IR
code is received from the air. receiveProc should contain the address of a
PUUCALLBACKPROC function defined as:
typedef void (WINAPI *PUUCALLBACKPROC) (char *IREventStr, void *userData);
When the USB-UIRT receives a code from the air, it will call the callback
function with a null-terminated, twelve-character (like IRMAN) ir code in
IREventStr. The driver will also pass the parameter userData, which is a
general-purpose 32-bit value supplied by the caller to
UUIRTSetReceiveCallback. This parameter is useful for carrying context
information, etc. Note that the types of codes which are passed to
IREventStr are *not* the same as the type of codes passed back from a
UUIRTLearnIR call (the codes from a UUIRTLearnIR are much larger and contain
all the necessary data to reproduce a code, whereas the codes passed to
IREventStr are simpler representations of IR codes only long enough to be
unique).
#define UUIRTDRV_IRFMT_UUIRT 0x0000 // For UIRT-native STRUCT or RAW
#define UUIRTDRV_IRFMT_PRONTO 0x0010 // For PRONTO
#define UUIRTDRV_IRFMT_LEARN_FORCERAW 0x0100
#define UUIRTDRV_IRFMT_LEARN_FORCESTRUC 0x0200
#define UUIRTDRV_IRFMT_LEARN_FORCEFREQ 0x0400
#define UUIRTDRV_IRFMT_LEARN_FREQDETECT 0x0800
Public Const INVALID_HANDLE_VALUE = -1
Public Const ERROR_IO_PENDING = 997
Public Const UUIRTDRV_ERR_NO_DEVICE= &H20000001
Public Const UUIRTDRV_ERR_NO_RESP = &H20000002
Public Const UUIRTDRV_ERR_NO_DLL = &H20000003
Public Const UUIRTDRV_ERR_VERSION = &H20000004
Public Const UUIRTDRV_CFG_LEDRX = &H1
Public Const UUIRTDRV_CFG_LEDTX = &H2
Public Const UUIRTDRV_CFG_LEGACYRX = &H4
Public Const UUIRTDRV_IRFMT_TRANSMIT_DC = &H80
*/ |
|
|
| Back to top |
|
 |
cynopsys
Joined: 27 Nov 2009 Posts: 43
|
Posted: Fri Jan 08, 2010 9:33 pm Post subject: |
|
|
Great!!
I succes to send ir signal directly from AutoHotKey
Thanks you for your code!!! |
|
| Back to top |
|
 |
cynopsys
Joined: 27 Nov 2009 Posts: 43
|
Posted: Sun Jan 10, 2010 2:23 pm Post subject: |
|
|
I don't understand this parts:
UUIRTDRV_API BOOL PASCAL UUIRTSetReceiveCallback(HUUHANDLE hHandle,
PUUCALLBACKPROC receiveProc, void *userData);
Registers a receive callback function which the driver will call when an IR
code is received from the air. receiveProc should contain the address of a
PUUCALLBACKPROC function defined as:
typedef void (WINAPI *PUUCALLBACKPROC) (char *IREventStr, void *userData);
I did this in the auto section of AutoHotKey:
getAirIrCodeAddress := RegisterCallback("getAirIrCode")
DllCall("uuirtdrv.dll\UUIRTSetReceiveCallback",UInt,hndl, UInt, getAirIrCodeAddress,Str,UserData)
getAirIrCode(IrEventStr,data){
tooltip %irEventStr%
}
irEventStr dont have the good data... I dont know why it dosent work! |
|
| Back to top |
|
 |
Thracx
Joined: 12 Mar 2007 Posts: 14
|
Posted: Fri Sep 17, 2010 7:34 am Post subject: Read IntPtr value |
|
|
| cynopsys wrote: | getAirIrCodeAddress := RegisterCallback("getAirIrCode")
DllCall("uuirtdrv.dll\UUIRTSetReceiveCallback",UInt,hndl, UInt, getAirIrCodeAddress,Str,UserData)
getAirIrCode(IrEventStr,data){
tooltip %irEventStr%
}
irEventStr dont have the good data... I dont know why it dosent work! |
What you have looks good, except you are not 'reading' the parameters passed into your callback function - they are pointers to the data, not the data itself:
| Code: | VarSetCapacity(IrCode, 12) ; Unnecessary if the destination variable is already big enough.
DllCall("lstrcpy", Str, IrCode, UInt, IrEventStr) ; Copy the string into the script's variable.
VarSetCapacity(IrCode, -1) ; Update the variable's internally-stored length to reflect its new contents.
tooltip %IrCode% |
It's been a long time since you posted this question, so if you have any additional information/progress on using USB-UIRT with AHK please do post it! I just got my unit in the mail and hope to work on an AHK script to use it. Thanks to this thread, I've gotten to the point where my callback is being called when I press a key on my Logitech Harmony 550 remote (which is pretending to be some random remote). |
|
| Back to top |
|
 |
JoeSchmoe
Joined: 17 Feb 2008 Posts: 303
|
Posted: Fri Sep 17, 2010 5:38 pm Post subject: |
|
|
| I have to say, that I'm quite tempted to get one or two of these... I'll probably resist, but my bet is that a standar library would be very well received among the more adventurous in our community. |
|
| Back to top |
|
 |
wtg
Joined: 04 Oct 2006 Posts: 210 Location: Louisville, KY
|
Posted: Fri Sep 17, 2010 5:58 pm Post subject: |
|
|
| Absolutely. I have one that I've long thought I should try to get working with AHK, but I've just never gotten a round to it. |
|
| Back to top |
|
 |
specter333
Joined: 15 Jan 2007 Posts: 527
|
Posted: Mon Jan 03, 2011 1:29 am Post subject: |
|
|
Hi Guys, this is the only place on the forum that I've found anything close to getting USB-UIRT functioning with AHK. Has anyone been able to advance this any further?
When I try running Laszlo's script AHK crashes on my system, not sure why. I've been using a USB-UIRT for years but I would love to be able to just use AHK instead of having another app run AHK scripts.
I'll keep studying this script but if anyone has anything new or insights I could use please let me know.
Thanks |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|