Help with visual basic UUIRTTransmitIR

Interested in integrating USB-UIRT support into an application? Look here!

Moderator: jrhees

Help with visual basic UUIRTTransmitIR

Postby ibartana » Thu Jan 13, 2011 1:02 pm

I am integrating USB-UIRT functions into a visual basic program, using visual studio, and am having a problem with the UUIRTTransmitIR function of the driver:

The code defintions are:
Code: Select all
    'USBUIRT infrared controller (only the needed functions)
    Public Declare Function UUIRTOpen Lib "uuirtdrv.dll" () As Long
    Public Declare Function UUIRTClose Lib "uuirtdrv.dll" (ByVal hHandle As Long) As Long
    Public Declare Function UUIRTTransmitIR Lib "uuirtdrv.dll" ( _
      ByVal hHandle As Long, _
      ByVal sIRCode As String, _
      ByVal uCodeFormat As Long, _
      ByVal uRepeatCount As Long, _
      ByVal uInactivityWaitTime As Long, _
      ByVal hEvent As IntPtr, _
      ByVal reserved0 As IntPtr, _
      ByVal reserved1 As IntPtr) As Boolean

    ' Global Variables:
    Public IRDriverHandle As Long 'hold USB-UIRT driver handle
    Public IRCode As String 'IR transmission code
    Public IRCodeFormat As Long 'IR transmission format


and the function I use looks like:

Code: Select all
   Public Function TransmitIR(ByVal IRCode As String, ByVal IRCodeFormat As Long) As Boolean
        'Transmit IRCode using IRCodeFormat. Returns True if successful, False if not.
        Dim res As Boolean
        If IRDriverHandle <> 0 Then 'USB-UIRT is open. Transmit IR
            res = UUIRTTransmitIR(IRDriverHandle, IRCode.ToCharArray, IRCodeFormat, 1, 0, 0, 0, 0) 'attempt to transmit. res holds result

            If res = False Then
                Return False 'Failed - couldn't transmit
            Else
                Return True 'Succeeded
            End If
        Else
            Return False 'Failed - no driver handle
        End If
    End Function


The error I'm getting on the UUIRTTransmitIR line is:
A call to PInvoke function 'Cinematics2!Cinematics2.ModuleIR::UUIRTTransmitIR' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

Which I gathered is a result of probably a mismatch in the type of the arguments - but I can't figure what's wrong.

Any help would be greatly appreciated.
ibartana
 
Posts: 1
Joined: Thu Jan 13, 2011 12:38 pm

Postby canoewhiteh2o » Sun Feb 20, 2011 11:58 am

You could use the USB-UIRT .NET wrapper. The wrapper takes care of the pinvoke for you. It can be downloaded here
canoewhiteh2o
 
Posts: 66
Joined: Thu Dec 28, 2006 1:52 pm


Return to Developers

Who is online

Users browsing this forum: No registered users and 3 guests