LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

build and test DLL with array

I am trying to convert a VI into a DLL using Application Builder.  I then want to substitute the DLL for the original VI in my code to test my DLL.  My DLL does not behave as expected -- I get back all zeros from my hardware instead of the values that I get when using my original VI.  I'm better at LabVIEW than C, so I'm not sure whether I am building my DLL incorrectly or calling my DLL incorrectly.  Does anyone see my error from this description?  Or is there some way that I can troubleshoot my DLL?  Here's some more info about what I'm doing...
 
 
When I build my DLL, I choose "Pass By" to be Array Data Pointer.  My other inputs are a handle (for communication with hardware) and the length of the output array (this input is added automatically because I chose Array Data Pointer).  My resulting function call looks like this:
void ReadStatus(unsigned long Handle, unsigned short data[], long len). 
 
When I call my DLL in LabVIEW with the Call Library Function VI, I select my array to be "Type" Array and "Array Format" to be Array Data Pointer.  I wired the output of Initialize Array to the left side of data, and I wired a constant to the left side of len.  The handle is also wired on the left side.  My resulting function call looks like this:
void ReadStatus(unsigned long handle, unsigned short int *data, long len).
 
Regards,
mlloyd
0 Kudos
Message 1 of 6
(2,855 Views)

In trying to isolate which part of my DLL is not working, I came upon something that could cause trouble...  the VI that I want to convert into a DLL is already calling external code through a library function call.  Can I still make this VI into a DLL?

 

Regards,

mlloyd

0 Kudos
Message 2 of 6
(2,850 Views)

Hi mlloyd,

I am not sure what the issue is.  I do believe that you should be able to convert a VI that is already calling a dll.  My recommendation for troubleshooting this issue is to create a debuggable dll.  If you are using LabVIEW 8.0 or later, when you build your dll in the Project Explorer, select the Advanced option and choose Enable Debugging.  From there, you can use that debuggable dll to see if you can pinpoint the issue.

Please let me know if you have any further questions by replying to this post.

Regards,
Ching P.
DAQ and Academic Hardware R&D
National Instruments
Message 3 of 6
(2,839 Views)

I selected Enable Debugging on the Advanced option in Project Explorer (LV 8.0) and built my DLL.  I then go to Operate»Debug Application or Shared Library.  For the Machine Name or IP address field, I tried typing my computer name, IP address, or "localhost" in the dialog box.  I attempted this while the VI containing my debuggable DLL was running and not running.  However, I always get the error

No debuggable applications or runtime libraries found

How do I start the debug process for my debuggable DLL?

 

Thanks,

mlloyd

0 Kudos
Message 4 of 6
(2,832 Views)
I was able to convert a VI that contains a call to a library function (in this case, a DLL) into a DLL.  I have isolated my problem to passing a hardware handle through multiple layers of library calls...  My handle is a U32 that I am passing as a value at each layer. 
 
I talk to my hardware via a DLL provided by my third party vendor.  I have some LV code and a call library function in a subVI.  When I convert my subVI to a DLL, my hardware does not respond as it should -- it behaves as if I have not opened a session with it even when I have already opened a session.
 
I remember reading somewhere that handles had to be initiated from the same process...  does anyone know the details of how this works?
 
Regards,
mlloyd
0 Kudos
Message 5 of 6
(2,820 Views)
Hi mlloyd,

Please take a look at Example 3: Call the Win32 API, on page 2-24, in the Using External Code in LabVIEW manual.  This example explains how to make this call using a U32 variable for the hWnd parameter.

If you have any additional questions, please let me know.
Regards,
Ching P.
DAQ and Academic Hardware R&D
National Instruments
0 Kudos
Message 6 of 6
(2,805 Views)