ni.com is currently experiencing unexpected issues.
Some services may be unavailable at this time.
05-22-2016 02:50 AM
title: Error 1097 Call Library Function Node, running LV 2012 SP1
date: 22may16
Hello LabVIEW Forum.
We created a software DLL for our product, and then performed an import of DLL to create the VIs.
Our DLL is actually an intermediate "dispatcher" DLL, which can cover different products, all of which have the same API, but different underlying DLLs.
We pass the real DLL name to this dispatcher DLL, which sets up pointers to the real function names in the real DLL (using GetProcAddress).
Then, each VI loads the appropriate API function for its inner workings.
I created the DLL, imported the DLL & header file to LabVIEW, which then created a set of VIs in a library.
The VIs seem to work OK, reading & writing proper values from/to the hardware, except that I get an "error out" value of 1097, Call Library Function Node error.
I looked on the internet and on the Forum, and was unable to find a solution to my problem.
Someone said - use Calling Convention stdcall instead of C; this did not work.
My first called function, initialization (Init_Module), has two input parameters of type "String", format "C String Pointer", with "Minumin Size" set to the suggested value of 8194. There are other Numeric parameters, too. One post said that the size of String output parameters can be a problem, but these are inputs, and the size is quite large (parameter is a short string of less than 30 characters).
I attach a ZIP file containing the full folder structure of my project: lvlib file & VIs, DLLs, C header file - which I understand are what someone would need in order to help. (Note: I imported only a partial set of the API functions, to get it working initially.)
I would most apprecuiate any help. Thank you.
Asher Meth
Excalibur Systems
ameth@ mil-1553.com
05-23-2016 02:41 AM - edited 05-23-2016 02:51 AM
Well, I'm not going to spit through the entire library to try to find possible errors and debug it for you. This is a major work and requires professional attention that goes way beyond volunteering support on a public forum.
Error 1097 always means that something inside the DLL went wrong and there was some corruption of some kind during the call to the function. It can be a stack mixup (e.g. bad calling convention, although that often quits LabVIEW right away hard) but most likely your DLL function simply overwrites some memory it is not supposed to do. The most common reason for that are output buffers (strings and arrays) that are passed to the function and are either not allocated in LabVIEW or are to small for what the function expects. And yes there is no way that the import library wizard could even start to guess how big such parameters need to be since the C syntax does not allow to specificy such "marginally" interesting details about how to call a function. The only way to know about such requirements is by reading the programmer reference manual of the DLL and hoping that the manual writer did actually understand that this is in fact very important information for a potential user of the library.
One note: The minimum size on your two parameters for the Initialize function sounds very misguided. Minimum size is only really necessary for buffers that the DLL function writes into, not for parameters that are passed to the function to be read and those two strings definitly sound like they are passed to the function to tell it where to find the dependent DLLs, not for the function to write in anything!
05-30-2016 07:29 AM
Hello Rolf.
I appreciate that you took the time to respond. I am not a LabVIEW expert at all, barely wet my feet. I am in the current position of developing this LabVIEW project based on other projects developed by former members of our team. They told me that there are real experts out there in the Forum, and that is *the* place to go to when you have questions.
I never intended for you to wade through the whole library (of some 50 VIs); just the first initizalization function, Init_Module. In fact, (I forgot to mention that) I purposely imported only a few functions from the DLL (creating less than 10 VIs), just to see if I was on the right track.
Concerning the DLL: The base DLL is ours which we created for this hardware product, and the dispatcher DLL (compiled in LabWindows CVI) is what I created in order to be able to use the same VI library with differently named underlying DLLs. This is something we have done on other projects.
Minimum size on two input parameters: This was not my decision, this was the default given by the Import tool. At the end of the day, this is not the problem. Given my lack of knowledge, I had hoped that someone would pick up on this and give a helpful comment.
The reason that I attached a ZIP file containing a folder including the DLLs and the imported VIs and associated VI library, is because I first looked on the forum for previous mentions of this error code. I saw that some of the responders said that they really need to see some VIs in order to be able to comment. So, I supplied them up front.
Being stuck, I went back to comparing my project to other working projects. And then I found the problem, which was (sort of) tangentailly mentioned in other posts. The 1097 error here indicated a clash between calling conventions. Our underlying DLL was compiled using __cdecl, since it was compiled under MS Visual Studio. We have other projects where the underlying DLL was compiled in Borland, using stdcall. My dispatcher DLL project was copied from a different project, which was apparently set to stdcall calling convention. This obviously clashed with the underlying DLL which had been compiled with __cdecl.
Once I recognized & fixed this problem, the error 1097 went away.
From my perspective, this topic is now closed. I hope that my experiences will help some other LabVIEW users out there.
Asher Meth
Excalibur Systems
ameth@ mil-1553.com