02-26-2008 10:22 AM
02-27-2008 03:22 AM
02-27-2008 03:25 AM - edited 02-27-2008 03:27 AM
Have you actually read the External Code Reference Manual? Do you understand basic memory mangement concepts of C? Based on your questions I doubt both and then things will get hairy anyhow eventually.
@bi wrote:
ok i walk through PDF's, saw some examples but i still don't understand, how to work with the simplest arrays in CIN. Problem is: i want that Labview read data from CIN and fill the 1D array. For example in my C code array declared as "unsigned char *Array1[7]" and after that i specify Array1[0] =6; Array1[1] = 4; Array1[2] = 23; ......... Array[6] = 12; So i created a CIN block, and wired it to Array numeric indicator and created .c file that looks like:
==================
/* CIN source file */
#include "extcode.h"
/* Typedefs */
typedef struct {
int32 dimSize;
float64 Numeric[1];
} TD1;
typedef TD1 **TD1Hdl;
MgErr CINRun(TD1Hdl Array);
MgErr CINRun(TD1Hdl Array)
{
/* Insert code here */
return noErr;
}
=================
Now, how to fill in this Labview array, with my values of "Array1" ?
2) Second question is, i have a program that reads data from PCIe board memory and returns it in pointer "ptr_to_pci_mem = (unsigned char *) mmap(NULL, PCI_MEM_LEN, PROT_READ|PROT_WRITE, MAP_SHARED, fd, (off_t)pci_mem_addr);"
How can I read data from this memory mmaped pointer and fill Labview 1D array with those values ?
Please help, thank you in advance.
02-28-2008 05:41 AM
02-28-2008 06:45 AM
02-28-2008 06:56 AM
02-28-2008 10:11 AM
02-28-2008 10:21 AM - edited 02-28-2008 10:22 AM
You changed the type def of the Handle in your C code to be an array of int32. The type you use in your C code of course should match the type you pass in from the LabVIEW diagram. You should make sure to also pass in an int32 array from the LabVIEW diagram and change the first parameter to NumericArrayResize from fD to iL.
@bi wrote:I've modified code to: MgErr err = NumericArrayResize(fD, 1, (UHandle*)*Array, i);
So now it works, but i got irregular data filled in Array, something like 1.E-106, 1.86... etc,I've even tried to set all the types to "int32" but this did not help 🙂
02-28-2008 09:59 PM
02-29-2008 09:53 AM