06-18-2008 10:52 AM
06-19-2008 11:10 AM
06-19-2008 11:53 AM
06-20-2008 02:46 AM
When you create an array or string or any variable on a diagram LabVIEW is behind the scenes mallocing the memory for you automaticially and when you pass such a wire to the Call Library Node it's memory address is passed to the DLL according to that parameter configuration. So unless your C function does want to resize, deallocate or otherwise change that memory pointer itself there is no need to know about what malloc was used.
@lmd2 wrote:
sorry, let me elaborate; the client has requested the driver by in LabVIEW 7.0
so error checking is minimal
the problem is that I don't know the LabVIEW version of malloc, memory allocation is done dynamically in the background, so how would I increase it by 1.5 or 2X?
the allocation is for a buffer which is filled if messages are present on the bus
thanx
lmd2
06-20-2008 03:51 AM
06-20-2008 04:07 AM - edited 06-20-2008 04:08 AM
Well it all depends on if this array is fixed size (unsigned short name[x]) or if it is just a pointer (unsigned short *name). In the first case the C compiler inlines the array and you can indeed treat it as an embedded cluster of the right (x) amount of elements, but in the second case you have to treat it as an uInt32 (uInt64 on the upcoming LabVIEW for Windows x64 platform) and do some other magic if you need to retrieve the values.
@lmd2 wrote:
Thank you
this sounds correct, although implementing it is going to take a bit of doing (actually the cluster does contain two arrays of U16, but no strings (arrays of U8)). Normally I can handle an array within a cluster by converting it to a cluster within a cluster - but in this case, this will make it more difficult to do a type cast.
But you have given me some insight and a direction -
thanx again,
lmd2
06-20-2008 04:54 AM
06-25-2008 09:19 AM
Rolf
In LabVIEW 7 when I configure the CLFN, even though I am sending in an array of bytes (U8) to allocate space, I will config the parameter not as an array, but adapt to type (I think) or should it be configured as an array? If 'adapt to type' then the data format would be either HANDLES BY VALUE or POINTERS TO HANDLES - I am thinking POINTERS TO HANDLES
On the other hand, if the parameter should be configured as an array of bytes, which of the three array formats should I use?
thanx
lmd2
06-25-2008 12:16 PM
06-25-2008 05:23 PM
Don't use any of the handle versions if all you need is an array pointer. A handle is a pointer to a pointer and also a special LabVIEW data type that can be resized anytime but only with LabVIEw memory manager functions. It is only useful for DLLs specifically written to deal with native LabVIEW datatypes and linking to the LabVIEW memory manager functions for doing that.
@lmd2 wrote:ok, adapt to type (any data format) crashes Windows - blue screen of death!!Array also crashes if data format is array handle, or array handle pointerthe only thing that doesn't crash windows is Array / array data pointer - which returns an error of "invalid buffer"since this is the only config that doesn't crash LV & WindowsXP I will try and get this config workingI am open to suggestions ...