LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to drive an USB device in LABVIEW using call DLL node!Thanks...

I have a USB device which is not manufactured by National instrument, but it has a dynamic link library (DLL) file. I tried to drive it in LABVIEW using call DLL method.

 

When the program runs, the error message is pop-up.

 

“An exception occurred within the external code alled by a Call Library Node. This may have corrupted LabView’s memory. You should have save any work to new location and restart LabView.”

 

The manual says the function is

Function EasyLaseWriteFrame (CardNumber:integer, DataPoint:pointer, Bytenumber:integer, Pointspeed:word):boolean

 

The declaration in DELPHI is

var

function EasyLaseWriteFrame (var cardnumber:integer; DataBuffer:pointer; DataCounter:integer; Speed:word):Boolean; stdcall; external ‘easylase.dll’;

 

Because I am not an expert in DELPHI, how should I correct my call DLL code in LABVIEW?

 

OS: Windows 98

LV version: 6.1 full development.

 

Thank you

0 Kudos
Message 1 of 3
(3,732 Views)

Read the paper about 'including external code in LabVIEW'. (Help-search the bookshelf)

The hurdles I run into where mostly because of datatypes. Some DLL claim to handle 8/16bit integer but the interface is handling with U32...

And always save before run Smiley Wink

 

 

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 2 of 3
(3,717 Views)


@CHENHY wrote:

 

The manual says the function is

Function EasyLaseWriteFrame (CardNumber:integer, DataPoint:pointer, Bytenumber:integer, Pointspeed:word):boolean

 

The declaration in DELPHI is

var

function EasyLaseWriteFrame (var cardnumber:integer; DataBuffer:pointer; DataCounter:integer; Speed:word):Boolean; stdcall; external ‘easylase.dll’;



This manual seems confiusing or maybe it is rather confused 😉
VAR parameters in Pascal (and Delphi is still Pascal in its syntax) mean that they are passed by reference. Nothing like this is however visible in the first description of the function.
If it is really a parameter passed by reference you should configure the LabVIEW CLN to use "Pointer to Value" for this parameter.
Also the second parameter is a buffer. It is mandatory that the caller (e.g. your LabVIEW VI) allocates that buffer before calling the function. To do this place an Initialize Array function on the diagram, wire an uInt8 constant to its type input and another constant to its size input specifying the number of bytes the buffer should have. Pass this same number also to the third parameter of the CLN to tell the function how much buffer space it can expect. Configure the second parameter of the CLN to be an Array of type unsigned 8bit integer, et voila.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 3 of 3
(3,697 Views)