LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading array from ActiveX function

Hello. I have ActiveX function that have 2 parametrs - number of variables to read from device and pointer to existing array. But this pointer in fact, is pointer to int variable, so in labview I can only link to this method numeric indicator and read first needed value. Is there a way to read rest?

0 Kudos
Message 1 of 5
(2,079 Views)

Hi Jaroslawjj10,

 

As this post wasn't touched for a month, do you still experience your issue regarding reading array from ActiveX function?

This could point you to right direction:

https://forums.ni.com/t5/LabVIEW/retrieve-camera-data-using-pointers-and-activeX/td-p/3790661

https://forums.ni.com/t5/LabVIEW/pass-a-pointer-to-an-array-from-Labview-to-OCX-activex/td-p/182600

https://forums.ni.com/t5/LabVIEW/Passing-pointer-to-array-to-activex-Method/td-p/338830

 

If you resolved issue on your own, could you share it with the community?

 

Hope this helps.

Regards,

Patrik
CTA, CLA
Helping (sharing) is caring!

If the post was helpful - Kudo it.
If the post answered your question - Mark it as Solution.
0 Kudos
Message 2 of 5
(1,997 Views)

@Jaroslawjj10 wrote:

Hello. I have ActiveX function that have 2 parametrs - number of variables to read from device and pointer to existing array. But this pointer in fact, is pointer to int variable, so in labview I can only link to this method numeric indicator and read first needed value. Is there a way to read rest?


If you can read the first element from a pointer, wouldn't the next element be at pointer+4?

0 Kudos
Message 3 of 5
(1,995 Views)

Actually just did this myself (but from .net):

MoveBlock.png

 

Message 4 of 5
(1,993 Views)

There is to little information in the original post about this to make a fundamental suggestion. What is most likely happening is that the ActiveX type library is declaring the parameter as "int *" type which is fine if you want to access such a function form C/C++ but an absolute no go for other environments that use the type library to generate interface code, such as what LabVIEW does. In C "int*" can be anything from a pointer to a single int to a pointer to an array of ints of 1 up to the maximum number of elements for the current enviromment which would be exceeding the addressable memory space. It could even be a pointer in disguise to something entirely different thanks to the very lenient aliasing rules in C that allow to typecast just about anything into anything else.

 

LabVIEW sees a pointer to an int and treats it as such. There is no way to change the view LabVIEW generates from the ActiveX type library that I'm aware of and you are stuck with this. I came across this problem with the Beckhoff ADS ActiveX library too, which is defined to take a pointer to a byte for the data buffer. I checked this by modifying the type library inside the ActiveX DLL to correctly declare that paramter as an array. Worked like a charm but that is of course not a solution. I had no intentions to go and analyse the DLL and locate its type library, search for the right location in the type library to add the according flag in there everytime Beckhoff might release a new version of the ActiveX library. Only useful workaround I could find was to read the target registers one by one with incrementing addressing and hence I eventually abandoned the ActiveX support entirely and used their DLL interface instead which has no such problems since the programmer is responsible to configure the Call Library Node correctly and there is no type library that can put LabVIEW on the wrong foot.

 

Basically the bug is in the ActiveX type library which declares the parameter in an ambigious way and wasn't created with Visual IDEs in mind that use the type library for something useful. Smiley LOL

Could LabVIEW support a way to reconfigure the ActiveX interface despite bad type library information? Sure! Would it be useful? Probably not much as you end up with the same difficulties as configuring the Call Library Node. Lots of ways to make it wrong and usually only one that is correct and it would require the developer to have programming insight into the ActiveX component that would be similar to wanting to call that component from C (yes C not C++, it can be done but is a pain in the ass as you need to do absolutely everything by hand).

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 5
(1,981 Views)