12-29-2009 08:30 PM
Hello,
I'm trying to allocate memory through using a buffer via LabVIEW. I understand I'm supposed to use an array, yet I'm not sure how I'm supposed to do this. Would you be able to provide an example, or provide an explanation how this is accomplished? I'd think it should be relatively easy to find how to do this, but I don't seem to be hitting the right sources.
Thanks,
Andrea
12-29-2009 10:19 PM
12-29-2009 10:38 PM
Hi,
The method to initialise the array is quite right, but be specific on what you want, probably your vi would help.
if you attach it here.
Regards,
shrek
12-30-2009 09:48 AM
In order to allocate memory into the buffers, here is the C code I am trying to accomplish:
/* Allocate memory for buffer */
pBuffer1 = (UCHAR *)AllocateMemU32(byteSize / 4 + 2)
In order to fill it, this is the C code involved:
/* Construct the start of the packet */
pBuffer1[0] = transmitLink;
pBuffer1[1] = g_usbport;
pBuffer1[2] = MENU_LOOPBACK;
/* Fill send buffer with random data, receive buffer with zeros */
FillBuffer((U32 *)(pBuffer1 + 3), byteSize / 4 + 1, DATA_TYPE_COUNT);
Thanks,
Andrea
12-30-2009 10:18 AM
You do not need to allocate memory at all, LV is doing this for you automagically.
There are several ways to get an array:
* Use the build array function (you can resize it, it allows inputs of single as well as array), this is fully dynamically and also works as AppendToArray.
* Use the Initalize array to get an array of defined size with all values initalized the same; Usful if you have large amount of data and are concerned about performance (then you use the replace array element function to set the values one by one or subset by subset)
* Use the autoindexing of a loop output (for- or while-, for gives optimal performance)
Please do not think the same way as when programming C or similar. Graphical programming has no variables but wires. Because each wire is mapped to a memory location, the wire itself has already the information for the compiler and you do not need (and hence they are not available as functions) use any of the MemAlloc, MemFree or similar...
Felix