LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing array pointer to ActiveX

Solved!
Go to solution

Hi

I am trying to control a TI 4100 DMD controller via the supplied ActiveX API (DLP Discovery 4100 Development Platform API Programmer's Guide). I have a connection to the DMD device and can perform basic commands such as IsDeviceAttached() using the ActiveX Methods.

 

However the command I need to use requires me to pass a pointer to an object:

 Short MemToFrameBugger(unsigned short* ImageBufferPtr)

I know that LabVIEW takes care of handling pointers when using the CLFN, but how could I find the address of the 'ImageBuffer' array to pass into the ActiveX Method? Is there an easy way or should I just use the alternate of CLFN calls to the supplied .dll?

 

Thanks

 

LabVIEW 2015, Windows 7

 

0 Kudos
Message 1 of 4
(3,333 Views)

Pointer handling is always tricky and just from the name of the function and the parameter datatype we can not say much about what needs to be done here.

What is this function supposed to do with the pointer? What is the memory location this pointer points to supposed to contain? Especially with image buffers you can't just take an arbitrary memory pointer and tell a library: Look this is an image buffer and try to use it!

The library will expect certain information in the buffer, usually a header that contains information about the image format and then the actual pixel data afterwards in a specific format that may be different for each library and also of course depend on the image header information.

What does the LabVIEW node look like when you access this function? What data type does the parameter have in LabVIEW? Most likely it will show as a 16-bit integer which simply means that the ActiveX Type Library is basically wrong and leads LabVIEW ashtray. As you can't really change the ActiveX Type Library in the DLL to make it correctly define this parameter as an array of 16-bit integers you are basically stuck with the ActiveX library.

When calling this function from C/C++ the type library isn't important and the header is all that is used. 

 

 

short *buffer;
short buffer[];

 

In C these two are basically equivalent and the C compiler doesn't care but for LabVIEW interpreting the type library, it makes a huge difference and you can't tell LabVIEW to interpret the type library in the ActiveX component in a different way.

 

With the CLN you won't have that problem as you alone are responsible for making the CLN configuration match the DLL interface, which for people not knowing C is usually an even bigger hurdle.

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 4
(3,167 Views)

Hi Rolf

 

Thanks for the detailed reply. I have done more work on it yesterday and have made some other calls work - converting and transferring an image file to the DMD.

 

The function takes an 1-bit depth 'image', which is just a 1D array with no header or other info, and loads it into the DMD controller board frame buffer. A later call loads this framebuffer onto the DMD display, switching the micromirrors on or off appropriately. Using other ActiveX functions in the library I can go from a named .bmp file to the framebuffer, but I need to dynamically update the framebuffer.

 

So I can create a suitable binary image array in LabVIEW, but I guess I would need to create a pointer to its first memory location, and also keep it valid so LabVIEW doesn't deallocate the array until it's been used. Which doesn't seem possible, so I will have to go the route of lower level commands via CLFN calls to the .dll.

 

Cheers

 

MemToFrameBuffer.png

 

0 Kudos
Message 3 of 4
(3,147 Views)
Solution
Accepted by topic author SuperDuperCooper

Your problem as you show in your picture is that LabVIEW interprets the Type Library for this ActiveX component to have an Int16 value passed by reference for the pointer variable. That is an error in the Type Library that should be fixed by the manufacturer of that library. There is no way to convince LabVIEW to make this a pointer or even more conveniently an array of Int16 values. The Type Library in the ActiveX component says: This is an Int16 passed by reference and that is what LabVIEW makes.

 

Unless you get TI to give you a new ActiveX DLL with corrected Type Library you can NOT correctly use this method in LabVIEW!! So if you need to use this function you have to bite the sour apple and use the DLL API through the CLN.

Rolf Kalbermatter
My Blog
Message 4 of 4
(3,023 Views)