LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ActiveX wrapper for Labview

Hello!
My name is Daniel. I'm from Argentina and I work in Tracnova S.A.
Tracnova is the Distributors of NI in Argentina.
I am having an issue with ActiveX development for wrapper an dll driver.

I have to read strain gage aquisition data from an USB device of MANTRACOURT (http://www.mantracourt.co.uk/products/wireless-telemetry).
The manufacturer provide an dll driver. It's shipped with example for VB6 that I have been testing and it works fine.
BUT I HAVE TO USE IT IN LABVIEW.
My first problem is that I have to provide an CALLBACK function pointer as parameter to "INITIALISE" function of the dll. Here is an excerpt from the

example that is shipped (Excerpt from a form module):

--------------------------------------------------------------------------------------------------------------------------------------------------
Private Sub Form_Load()
    'we will only handle base station addresses of 1
    iBaseAddress = 1
    Caption = Caption & " [DLL v" & VERSION & "]"
    CLOSEPORT
    'set the callback so we can receive data provider packets
    Init AddressOf CallBack  ''''''----------------->>>>>>>>>>>>>>>> CALLBACK function pointer as parameter to "INITIALISE" (It defined as Init)
    'Open USB interface
    ok = OPENUSB
    If ok <> 0 Then
        ShowMessage "Cannot open USB interface!" & vbNewLine
    End If
End Sub
---------------------------------------------------------------------------------------------------------------------------------------------------

"CallBack" function is contained within .bas. Because You can only retrieve the address to a function or sub (public or private) contained within a

Standard VB Module.  There's no way around this.

Here is an excerpt from the example that is shipped (excerpt from a Standard Module):

-----------------------------------------------------------------------------------------------------------------------------------------------------
Sub CallBack(ByRef StringPtr As Long, Length As Long)
    Dim PBMsg As String, rc As Long, pEnd As Long
    Dim p(128) As Byte
    Dim cH As Byte
    Dim tID As Long
    Dim C As Integer
    On Error Resume Next
    CopyMemory p(0), ByVal StringPtr, Length
    PBMsg = Left$(StrConv(p(), vbUnicode), Length)
    'strip off the base station wrapper
    PBMsg = Mid$(PBMsg, 4, Len(PBMsg) - 5)
    If PBMsg <> "" Then
        Debug.Print CVStr2HEX(PBMsg)
        Select Case Asc(Mid$(PBMsg, 1, 1)) And &H1F
        Case PT_DATA_PROVIDER
            'pass data to the main form if we are not closing
            If Not Closing Then MainFrm.ShowMessage "DATA_PROVIDER Data Tag=" & Replace$(CVStr2HEX(Mid$(PBMsg, 2, 2)), " ", "") & " Data=" & Decode

(Mid$(PBMsg, 5, Len(PBMsg) - 6)) & vbNewLine
        End Select
    End If
End Sub
-----------------------------------------------------------------------------------------------------------------------------------------------------


Then, when an data packet arrived, the driver call to "CallBack" function instead, so I can process it and do what I need.

But I can't pass pointer to function IN LABVIEW WITH "LOAD LIBRARY FUNCTION". So I did an ActiveX in VB6 for wrapping the dll of the driver. I attached the

files tha I did. The ActiveX sends an event to labVIEW everytime that a data packet arrived. I trigger an event inside the CallBack function that it's

not working, but if outside (look inside Iniciar() function where I wrote "This is the first event", the event trigger works.)
Why is not THE CALLBACK FUNCTION TRIGGERING THE EVENT INSIDE THE LABVIEW??

 

I also tried to make a Win32 DLL with C + + using PostLVUserEvent, but neither worked for me. I can send the code in C + + if you want to review.


Thank you for your consideration. I look forward to hearing from you.

Best Regards

 

Daniel Lopez

Design Engineer

TRACNOVA SA

www.tracnova.com

 

 

0 Kudos
Message 1 of 4
(2,961 Views)

They claim to have COM driver. Have you looked into that? You maybe able to use them with LabVIEW's ActiveX functions.

0 Kudos
Message 2 of 4
(2,953 Views)

Thanks a lot nyc for your kind reply.

Yes, you are right. They have COM driver, but the event does not fire in labview. Also, this driver does not implement a COM circular buffer which means that if you delay reading and processing the data, these are lost because they are rewritten. I have been asking for support to MANTRACOURT, but after several attempts, they told me they do not provide support for labview only for VB, VBA excel, and some other more, not even C + +    😞 

 

National I miss to much. Nice technical support !

Please help, I need to fix this issue


 

Thanks a lot!

 

Daniel

0 Kudos
Message 3 of 4
(2,947 Views)

I worked with ActiveX events (from Flash, though), events work fine.

Thera are two things that confuse me: 

1) Can we consider a constant to be a good activex object? Try placing an ActiveX container (on Front Panel) and insert your object into it.

2) There is no project. VIs and object work in main application instance. Can it have some limitations?

0 Kudos
Message 4 of 4
(2,935 Views)