LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

An imported Share Library (DLL) function expects INTEGER POINTER to the beginning of an array to be passed in

We need to pass an Integer Pointer that references the start of an array. We need to know if there is a mechanism to provide this pointer within LabView.

unsigned short aData[34]; LoadBCDataBlock(Card, nMod, nBCChan, usDataBlock, 32, &aData[0]); I need to know if there is a function or some operation that can provide this INTEGER POINTER needed by a certain C functions in a DLL library that this board manufacture provides. I understand there is the MoveBlock function in LabView but I can never get the functions parameters to program (broken wires). Any insight to this would be helpful.
Einstein proved by taking time in thinking about a problem he proved there is no such thing as gravitational pull. Therefore, given enough time and thought a problem can be solved. If the problem is not solved then there has not been enough thought.
0 Kudos
Message 1 of 15
(3,856 Views)

No need for MoveBlock. When you pass an array to a DLL, with the data format configured as Array Data Pointer, LabVIEW passes a pointer to the first element of the array. All you need to do here is initialize an array of U16 with the correct number of elements (34, apparently), using the Initialize Array function, then pass that as the aData parameter.

 

If that's not clear, please post your VI showing the call to the DLL, as well as the prototype for the function you're trying to call (ideally, the entire header - .h - file).

0 Kudos
Message 2 of 15
(3,851 Views)

I  have been looking at manypost and everything written about pointers and MoveBlock. I have not seen one example that a guy like you explained whichshow exact what you ar talking about. I initized the array but the out is an array aand not the pinter to the array. Look at the pic and tell me the missing ingredient. Much appreciate the help.

Einstein proved by taking time in thinking about a problem he proved there is no such thing as gravitational pull. Therefore, given enough time and thought a problem can be solved. If the problem is not solved then there has not been enough thought.
0 Kudos
Message 3 of 15
(3,845 Views)

It's difficult to help when you ask about one function in your first post, then show an image of a completely different function as a follow-up.

 

Please provide the header file for the DLL, the VIs, and any documentation or at least the order in which you intend to call the functions. Then we'll know we're both talking about the same thing. Without any documentation, there's no way to know what the function in your image is supposed to do, nor whether the import shared library wizard generated the VI correctly. Due to ambiguity in C prototypes, the shared library wizard cannot always determine what data type to use for some parameters. For example, int *data could be a pointer to a scalar, or an array. It seems likely that in your image, the intarray parameter should actually be an array, and the documentation would confirm that. If so, you need to adjust that VI, and the Call Library Function Node inside it.

 

The import shared library wizard is helpful, but you still need some understanding of C in order to call a function in a DLL properly.

 

Please save the VIs for LabVIEW 2012, I'm still using that version.

0 Kudos
Message 4 of 15
(3,826 Views)
Sorry I do not have 2012 32bit which tis DLL was compile. This TESTARRAY is an example code that I am using to test with. It is similar to what I am doing. There are three functions to load, modify and retreive an array.
Einstein proved by taking time in thinking about a problem he proved there is no such thing as gravitational pull. Therefore, given enough time and thought a problem can be solved. If the problem is not solved then there has not been enough thought.
0 Kudos
Message 5 of 15
(3,816 Views)
Sorry I do not have 2012 32bit which tis DLL was compile. This TESTARRAY is an example code that I am using to test with. It is similar to what I am doing. There are three functions to load, modify and retreive an array.
Einstein proved by taking time in thinking about a problem he proved there is no such thing as gravitational pull. Therefore, given enough time and thought a problem can be solved. If the problem is not solved then there has not been enough thought.
Download All
0 Kudos
Message 6 of 15
(3,816 Views)

The following three APIs are in the TestArrayDll :

 

/* Copies the data passed in the intarray argument to the internal array.

   Returns the number of elements copied to the internal array.

   -1 returned if count is greater than 100.

*/

_TESTARRAYFUNC_INT LoadArray(int count, int *intarray);

 

/* Modifies the internal array by adding the value passed to the modifyWith argument.

   Returns the number of elements modified in the internal array.

   -1 returned if count is greater than 100.

*/

_TESTARRAYFUNC_INT ModifyArray(int count, int modifyWith);

 

/* Retrieves the contents of the internal array and

   returns the data in the intarray argument.

   -1 returned if count is greater than 100.

   */

_TESTARRAYFUNC_INT RetrieveArray(int count, int *intarray);

 

 

The TestArrayApp has code to illustrate how to call each of the APIs. If this all makes sense to you, the next step is to port the TestArrayApp to LabView.

Note, if you look at the code in TestArrayApp, since we are dealing with one-dimensional arrays, C will allow arrays to be passed either way:

      //LoadArray(elementCnt, myArray);

      LoadArray(elementCnt, &myArray[0]);

Einstein proved by taking time in thinking about a problem he proved there is no such thing as gravitational pull. Therefore, given enough time and thought a problem can be solved. If the problem is not solved then there has not been enough thought.
0 Kudos
Message 7 of 15
(3,815 Views)

This translates easily to LabVIEW. Use a For loop or Initialize Array to create an array of up to 100 integer elements. In the Call Library Function Node setup, configure the intarray parameter as an array, passed by Array Data Pointer. That's all. No moveblock, no complications. The shared library import wizard won't get this right because it doesn't know that intarray is an array. You'll need to modify the generated VI to replace the scalar with an array and then adjust that parameter in the Call Library Function Node setup; or, skip the wizard and set it up yourself.

0 Kudos
Message 8 of 15
(3,811 Views)

I have done what have suggest and every time the array will not wire into the integer pointer. I setup again and show you whe r e I am getting stalled.  If this is easy as you explained why  isn't there an example. I must be missing a key ingredient that is being skip over because I can never get the vi wired. When I am back at my desk I will try it And let you know. 

Einstein proved by taking time in thinking about a problem he proved there is no such thing as gravitational pull. Therefore, given enough time and thought a problem can be solved. If the problem is not solved then there has not been enough thought.
0 Kudos
Message 9 of 15
(3,796 Views)

You shouldn't have an integer pointer at all; it should just be an array. You have three options:

1) Delete the LabVIEW library that the shared library wizard created, then re-run the wizard. There's a step in the wizard where you can fix function parameters. Adjust it so that the array parameter is actually an array.

2) Edit the VIs that were generated when you previously ran the shared library wizard. Replace the integer parameter with an array, and inside the VI, reconfigure the Call Library Function Node so that it correctly expects an array.

3) Don't use the shared library import wizard at all, and configure the Call Library Function Node yourself.

 

You can pick any one of these options, but in the end you MUST end up with a call library function node where the array parameter is configured as an array. This is NOT the default for the shared library import wizard, but again, that wizard cannot determine whether a pointer is supposed to be an array or a scalar, so it defaults to a scalar. It sounds like you're expecting the default output of the wizard to be correct, whereas you actually need some knowledge of C to use it properly.

0 Kudos
Message 10 of 15
(3,781 Views)