LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass LabVIEW array to invoke node that expects UInt32* pointer type?

Hi,

 

I understand from reading other posts that LabVIEW does not directly support pointers, but I'm hoping someone may know a way around this wall I've run up against.  I'm working with a third party API that uses .NET4 and trying to get it to work with LabVIEW.  I followed the instructions to configure LabVIEW to run with .NET4.  I'm using LabVIEW 2011 on a Win7 Enterprise, 32 bit, Service pack 1 machine. One of the functions in the API requires an array pointer type input, UInt32*, but I could not figure out how to interface using the "To .NET Object VI".  Is there some way to do this?  Attached is a partial screenshot of what I tried.  The .NET object that is wired to the target class of the  "To More Specific Class Function" was created by using the Create Constant of the "data" on the invoke node, which is the same type as the "control". When I run the test, I get:

 

Error 1057 occurred at To More Specific Class in EuvisLabVIEW_v0p0p3.vi

Possible reason(s): LabVIEW:  Type mismatch: Object cannot be cast to the specified type.

 

Is there any other way to pass the array from LabVIEW to the invoke node?  Any insight would be greatly appreciated.

0 Kudos
Message 1 of 8
(3,160 Views)

You can get a pointer in LabVIEW by using LabVIEW's built-in functions, accessible through a call library function node with the library name set to "LabVIEW".  To obtain a pointer you'll need to use DSNewPtr; use MoveBlock to copy data into or out of that memory; and use DSDisposePtr to release the memory when you're done with it.  These functions are all described in the LabVIEW help and there are many examples of them on this forum.

0 Kudos
Message 2 of 8
(3,151 Views)

I have this exact problem aswell (trying to use the Euvis drivers with custom waveforms) Did you finally resolve this?

 

Regards

Kalle

0 Kudos
Message 3 of 8
(3,058 Views)

Hi Kalle,

 

You may want to take a look at the functions mentioned by nathand above. There is also a library function node under mscorlib(2.0.0.0) called UIntPtr that has a ToPointer Method. Could you post some more details of what you are trying to do with your data?

Zach P.

Staff Software Engineer | LabVIEW R&D | National Instruments
0 Kudos
Message 4 of 8
(3,034 Views)

Also, you may want to take a look at this example:

 

https://decibel.ni.com/content/docs/DOC-9080

Zach P.

Staff Software Engineer | LabVIEW R&D | National Instruments
0 Kudos
Message 5 of 8
(3,030 Views)

Hello

 

The problem is that I cannot pass the pointer to my data array since the .NET invoke method recognizes the array reference as a .net refnum of type UINT32.

 

The function prototype looks like this:

Void user_define_bulk( UInt32* freqArray, UInt32 arraySize )

 

Using your input above i attempted to use the pointer methods, but to no avail since the "to more specific class" still fails with error 1057 when trying to cast the pointer to uint32*.

 

Any more ideas?

 

Regards

Kalle

0 Kudos
Message 6 of 8
(3,020 Views)

Did you try using "Variant to .NET Object" instead of "To More Specific Class"?

 

Although... the pointer there is just a C-style array.  I wonder if you could pass an array directly to that function instead of a pointer.  I don't know enough about .NET to know how it handles arrays, and whether it's like C in memory layout.

0 Kudos
Message 7 of 8
(3,003 Views)

Hi,

I ended up going around my original problem by using a C Sharp dll and LabVIEW's .NET constructor node.  The C Sharp code takes a "regular" array from LabVIEW, then converts it to a pointer type using an "unsafe" code block.  The solution works ok.  However, I seem to still have an intermittent and infrequent bug ( occurs maybe ~ 1 out of 1000 waveform loads) that I could never fix, so I have the program "restart" when it encounters the problem.

 

photonlab

0 Kudos
Message 8 of 8
(2,985 Views)