07-19-2007 12:16 AM
@happybird wrote:
Hello,If we create a device driver instead of a DLL file, can we use labview VISA to communicate our device? I have talked to the guy who created the DLL file, he insist that the DLL can only be used by TCL ,can not be used by LABVIEW. so he is trying to create a device driver, but can i use VISA to talke to the device when the driver is ready?Mike
What do you mean by a device driver? Is your device some sort of hardware?
I can think of two device drivers. Kernal device drivers and user space device drivers in the form of DLLs. For both VISA won't help you a single bit.
If it is a kernal device driver you will have to write a user space DLL that accesses the device driver and then call that user space DLL from LabVIEW. This user space DLL is necessary since you need to call specific Windows APIs to communicate with a device driver and some of them can get nasty to be called directly from LabVIEW. Also there are typically quite a lot of Windows API functions that need to be called for communication with a device driver and that is something which can get a bit tedious to do in LabVIEW as you have to do all the nitty bitty work of finding the exact parameter types, offsets and translations between the required parameter types and what works best in LabVIEW yourself, that a C compiler does normally for you.
If it is just a user space device driver DLL you can directly access that from LabVIEW with the Call Library Node.
Rolf Kalbermatter
07-19-2007 11:00 AM
07-19-2007 11:21 AM - edited 07-19-2007 11:21 AM
@happybird wrote:
Hi Rolf,Thanks for your explanations, we have modified the original DLL file, now I can use labview : "call function node.VI"to call the windows API functions, the functions including Findthehid(), Getdevicecapabilities(), CloseHandles(), Prepareforoverlappedtransfer(), Readinputreport(), Writeoutputreport(), Registerfordevicenotifications(). but I am still not clear on how to use these functions to communicate with the HID device by Labview, do you have an labview example on using these functions to talk to the HID device?Mike
I can't tell you. Those functions are NOT standard Windows APIs (at least MSDN doesn't seem to know about them) so they probably come from your DLL. Only the programmer of that DLL can tell you how to call those functions.
However there is a good chance that some of the functions will be tricky to call directly from within LabVIEW because of complicated parameters (structures) or things like event handling (RegisterForDeviceNotifications()).
Rolf Kalbermatter
Message Edited by rolfk on 07-19-2007 06:22 PM
07-19-2007 06:10 PM - edited 07-19-2007 06:10 PM
Message Edited by happybird on 07-19-2007 06:18 PM
07-20-2007 02:54 AM
@happybird wrote:
Hi rolf,Attached is the code I have to call the DLL, we have rebuit the DLL, but when I call the function in labview, labview will always return error message"an error occured in external code, it might have corrupted labview memory..." so is the code i attached any problem? or is it the problem of the DLL? the following is the code for the DLL.int commandinterp (char cmd_line[]) {if (strncmp (cmd_line,"xwr", 3)==0 {outputreport[1]=*strtok (cmd_line, " ");outputreport[2]=*strtok (Null," ");outputreport[3]=*strtok (Null, " ");else if (strncmp (cmd_line, "xrd",3)==0){outputreport[1]=*strtok (cmd_line, " ");outputreport[2]=*strtok (Null," ");Readinputreport()}else{printf ("error"\n)return(-1);}MikeMessage Edited by happybird on 07-19-2007 06:18 PM
I simply don't understand what you want to do. First you talk about a DLL with specific APIs like FindTheHID() etc. Then you show me some scriptic C code which by the why won't compile without error and without much of a definition and a VI which might or might not be related to that code.
It seems to me that the function you show above is what you try to call in the VI. If that is the case then I would say you got the return value wrong. The function specifically returns an int but you try to make LabVIEw read a string from it. Bad! Bad!
As for the further going of this topic, you will have to find the rest yourself. Not only does this not seem to lead anywhere but I'm also off for some vacation and won't have internet access there
Good luck
Rolf Kalbermatter
07-21-2007 08:13 AM
Enjoy the vacations, Rolf.
Hi Mike.
To get rid of the LabVIEW error message I propose to create a simple function like
int __declspec(dllexport) __cdecl commandinterp (char cmd_line[]) {
return (-1);
}
As the code is doing nothing there is almost no chance for a crash.
The attached VI can be used to call this function.
Parameter and return value are already configured.
I removed the path to the DLL in the Call Library Function Node -> Specify your DLL.
Hope this helps, Guenter
07-31-2007 05:59 PM - edited 07-31-2007 05:59 PM
Hi Rolf,
I have tried to understand the VIs in OGPIPE.llb, but I am still confused about how to implement these VI to embbed my TCL command in Labview, as there's no readme file, I am not even sure which VI is the main program, have you ever used these VI for the same purposes? do you have an example to use these VIS to embed other program in Labview? Thank you,
Mike
"If it is only to launch external tools then yes. Just place a string control and pass its contents to the System Exec.vi function.
If you want to embed the external tool standard IO in LabVIEW you will have to use standard IO redirection. Not exactly something trivial but on OpenG there is a library in Beta state called Pipe which does redirection of the standard IO of command line tools into pipes so that you can write to the standard input of such a tool and read the standard output and standard error.
As mentioned it is still in Beta state, but works for what I needed it, but more testing is required before it can be packed into an OpenG package to be installed with the VIPM.
Rolf Kalbermatter"
Message Edited by happybird on 07-31-2007 06:01 PM
08-01-2007 03:08 PM
08-01-2007 04:10 PM
08-02-2007 08:32 AM