LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading activex safarrays into labview

I am trying to use the Olympus SDK activex drivers to control a digital camera. Everything works except downloading the pictures. The Activex driver requires a 1d U8 array and returns a SafeArray. I cannot get Labview to correctly read in the SafrArray from the property node (I have tried configuring a clusterlike the safearray and wiring that to the type input of the variant to G but the data is unchanged). It just returns the 1d array i pass into the property. From the timing it seems the camera is actually transferring the data, and a C++ program using the same drivers works perfectly. How do you read a safearray into labview?
Download All
0 Kudos
Message 1 of 5
(3,065 Views)
Arran,

There are two ways you could go about this.

The first would be to create a cluster with the same data types as a SAFEARRAY and use the to G DATA vi.

Here is the structure for a SAFEARRAY:

typedef struct tagSAFEARRAY
{
USHORT cDims;
USHORT fFeatures;
ULONG cbElements;
ULONG cLocks;
PVOID pvData;
SAFEARRAYBOUND rgsabound[ 1 ];
} SAFEARRAY;

So you could make a cluster with these same data types in it, in the same order. A USHORT is an unsigned short (U8), and ULONG is unsigned long (U32) and PVOID is a pointer to the data and SAFEARRAYBOUND is another cluster with this structure:

typedef struct tagSAFEARRAYBOUND
{
ULONG cElements;
LONG lLbound;
} SAFEARRAYBOUND;

Here's a web page that describes all the different paramters:

http
://msdn.microsoft.com/library/wcedoc/wcemfc/struct_25.htm

The second is possibly the better/easier way to do this. You could write a wrapper DLL in C code that just passes out the array, which is all you really care about. That way you wouldn't need to worry about creating the cluster just right.

Regards,

Cyril Bouton
Applications Engineer
National Instruments
Cyril Bouton
Active LabVIEW Developper
0 Kudos
Message 2 of 5
(3,065 Views)
Thanks Cyril. Just one question though. How do I make the PVOID pointer in the cluster? If I wire an array to the cluster does it not store it as a handle rather than a pointer?

Regards

Arran
0 Kudos
Message 3 of 5
(3,065 Views)
PVOID is just an I32 representing the pointer.

Cyril
Cyril Bouton
Active LabVIEW Developper
0 Kudos
Message 4 of 5
(3,065 Views)
OK, now I have a pointer to the data how do i actually read it into a labview array?

Thanks

Arran
0 Kudos
Message 5 of 5
(3,065 Views)