LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

dll buffer string

I have been programming with LabView for about 15 years and have used tons of DLLs from LabView so this isn't my first time.  I purchased a slick USB based isolated 6 channel voltmeter from EtherTek Circuits.  They provide a DLL that they wrote in assy.  I can access the DLL and get it to answer back using their DLL test function, but when I try to get any data back from any other functions such as even getting a list of the devices, it has a problem.  Either it returns an empty variable or with some jibberish that doesn't follow any rhyme or reason.  They have an app that uses the DLL and it talks to the the hardware just fine. 

 

The developer wrote the DLL so that you passed the DLL a buffer and it then filled the buffer.  Here is a sample of the DLL code for a simple function.

 

GetManufacturerString proc pid:DWORD, buffer:DWORD
 
 LOCAL unicodebuf [512]
 LOCAL asciibuf [512]
 
 invoke OpenHID,pid
 invoke HidD_GetManufacturerString, hHIDDevice, ADDR unicodebuf,512
 invoke CloseHID
 invoke UniToAscii,ADDR unicodebuf,ADDR asciibuf
 invoke szCopy,ADDR asciibuf,buffer
 mov     eax,TRUE
 ret

GetManufacturerString endp

 

Can someone enlighten me on how to format the DLL call?  I have tried just about every combination of datatype definition in the configure dialog.

 

The complete assy for the DLL is attached

0 Kudos
Message 1 of 9
(3,262 Views)

When I did the copy and paste it converted the :DWORD to a smiley, sorry.

0 Kudos
Message 2 of 9
(3,260 Views)

Well the forum keeps converting a   colon DWORD to a smiley. 

0 Kudos
Message 3 of 9
(3,259 Views)

Its been a long day.  I forgot to mention that this is LV2010.

 

😄

 

0 Kudos
Message 4 of 9
(3,257 Views)

Do they provide the source code for their working sample app?  That would be helpful, especially if it's in C.

0 Kudos
Message 5 of 9
(3,254 Views)

Quick web search turns up what appears to be their sample code.  Admittedly not terribly helpful.  However, the C# example appears to provide enough information to be able to configure the Call Library Node in LabVIEW.  The functions are as follows:

 

        private static extern int TestDLL(byte[] buffer);
        private static extern int FindUSBisoVMs(byte[] buffer);
        private static extern int GetManufacturerString(int ID, byte[] buffer);
        private static extern int GetProductString(int ID, byte[] buffer);
        private static extern int GetVersionString(int ID, byte[] buffer);
        private static extern int ReadUSBisoVM(int ID, int VM, int FORMAT, byte[] buffer);

In calls to those functions in the C#, buffer is 1024 elements.  In LabVIEW, use initialize array to create an array of 1024 U8, then pass that to the function calls as array data pointer.  It looks like you'll then need to use Array of U8 to String to convert the buffer data into a string, then parse the necessary data from that.  All of the other data types are clear.

0 Kudos
Message 6 of 9
(3,250 Views)

I've actually tried that but will give it another go.

 

It looks like they wrote their little app in assy as well.

0 Kudos
Message 7 of 9
(3,246 Views)

It still is doing the same thing.  I attached the VI. and the DLL.  The names have been changed to protect the innocent.

 

Is this what you were thinking?

 

Notice that the first call I actually used a standard String data type and it returned the correct info.  It doesn't work on the second call.

 

This hardware is really nice and I hope to use it alot.

 

Test DLL.txt is the VI and the other is the DLL

Download All
0 Kudos
Message 8 of 9
(3,245 Views)

AS it turns out, the VM got hung up due to a bad call.  Once I powered down and back up, I was able to get it to talk.  I would have expected it to throw a code, but it gave a good return code but a not good response.

 

 

0 Kudos
Message 9 of 9
(3,239 Views)