04-06-2015 12:13 AM
Hi everybody...
i have to pass a void variable to a function but i have some problems.
The function that i have to pass is defined like this picture.
[IMG]http://i60.tinypic.com/2ut6l9d.jpg[/IMG]
Therefore i set my function in this mode:
[img]http://i62.tinypic.com/o0xa2o.png[/img]
But when i run the program i gives me this error
[img]http://i62.tinypic.com/2mobbxh.png[/img][/quote]
I think the problem is linked with pRes variable that in the definition of the function is a Void type, but in my program i don't know how to pass a void variable.
Can someone help me?!
04-06-2015 12:22 PM
This forum allows you to post images directly. Please do that instead of posting links (especially since some of your links are broken) to unknown outside servers. Even better, when you are describing text code, post the TEXT!
04-06-2015 01:30 PM - edited 04-06-2015 01:32 PM
Just what nathan said. Links on external sides are pretty undesirable, especially on sites like the one you use, where one never can be sure that it doesn't try to "provide" one with scare ware or other undesirable stuff, when clicking somewhere by accident, besides that I don't really trust such sites to not try to download hidden programs, either as part of their "businessmodel" or unintentiionally since they are attractive targets to get hacked for such purposes.
Apart from that, you need to understand a bit about C programming. It's not a void parameter that your function has but a void pointer. That is a whole lot of a difference. (You can't define a function having a void parameter, as that would be completely useless). A void pointer in C is used to indicate a parameter that can get assigned any valid pointer datatype. Which actual pointer type the function actually expects usually depends on the actual context and often specific other parameters that tell the function what it should expect.
Just because you select adapt to type as datatype because LabVIEW uses there also void* as datatype does absolutely not mean that the datatypes match. Again void* can mean any kind of pointer. Which one has to be determined based on the funciton description and often depends on other parameters to your function. Once you know what the function expects you have to find the according datatype that LabVIEW can provide. This is almost certainly not an Adapt to Type type, since that is the datatype that will pass the LabVIEW variable as native datatype to the function. For skalars this means that LabVIEW passes a pointer to that skalar, for arrays and strings it will pass the LabVIEW handle, which is certainly not what the DLL expects unless the DLL is specifically written to interface to the LabVIEW Call Library Node, by someone who knows what native LabVIEW datatypes mean.
04-08-2015 05:29 AM - edited 04-08-2015 05:29 AM
I'm sorry for posting image wrongly...
Here i tried to pass some parameters to my function but it doesen't work correctly.
Can someone help me?! I don't know where i am making a mistake
Thank you very much
Giovanni
04-08-2015 06:13 AM
You are talking about a PviCom.dll:PviInitialize as "your function" , I don't think anyone will be able to help you with this without the dll.
I would suggested you check the manual that comes with the dll and an example of how it's accesed. Your vi looks ok.
04-08-2015 06:36 AM
Yes!!
I am talking about PviCom.dll, in particular PviInitialize function...
In atteachment there is the declaration of the function and also an example. I think i am not making mistakes... But i can't understand why labview returns me error 1517...
04-08-2015 06:43 AM
Just what doesn't work? How do you determine that it doesn't work? By the way you are going to be in even deeper problems to get the Windows message mechanisme working that your DLL seems to require.
04-08-2015 06:50 AM
Because labview gives me the error 1517 meaning that there is a mismatch between function of the dll and parameters that i pass to the function...
04-08-2015 07:02 AM - edited 04-08-2015 07:03 AM
Two things then:
1) Are you sure your function uses cdecl and not stdcall?
2) I assume you run in 32 Bit LabVIEW but if you ever plan to use 64 bit LabVIEW it would be better to define the last parameter as pointer sized integer instead.
04-08-2015 07:07 AM
You are wright!!!!!
The problem was that i used cdecl and not stdcall... Using stdcall it works correctly.