Pointer to LabVIEW Array

LabVIEW memory management question:
Question Part 1: When I write a C .dll that takes a LabVIEW array,
LabVIEW passes a pointer into LabVIEW's memory to the array to C. 
Can C return the pointer to me (e.g., not the array I passed in, but
it's memory location)?
i.e.: void GetNativeMemoryPointer(float *pointer, float *array);
where *array is my input array, and GetNativeMemoryPointer returns the pointer to this array on *pointer.
Question Part 2: What issues will I run in to if I pass this returned
pointer to another .dll call.  What if this .dll call is in
.NET? 
Concerns: How does LabVIEW hold this array in memory?  When I call
GetNativeMemoryPointer, does LabVIEW make a copy and send this a
pointer to the copy to the dll, or is the pointer to the
original?  Will LabVIEW ever "move" the original, e.g., will my
pointer become invalid after some time?
Joe Gerhardstein
Averna Test Systems
Certified LabVIEW Architect
http://www.averna.com

Part 1: I must confess that I don't understand your question. Pointers and arrays are very closely related in C so I'm not following the sequence. So I don't know if the following applies, but here is a possible answer...
The pointer to a LV array that is passed to a call library node is valid ONLY during that call. Once the call to the DLL completes, you should consider that pointer value invalid. You can, of course, make a copy of the array and return a pointer to your copy - but LV won't know what it is. It definately won't show up in LV as an array. However, you can pass that pointer to the copy around to other DLLs as much as you want.
* Don't forget to free the copy. If you make a copy of the array, you own it - therefore you must free the memory of the copy at some point *
Part 2: Easier to answer.
* If you want LV to convert your pointer to a LV data type (such as a LV array): Take a look at page 2-4 in the "Using External Code in LabVIEW". In almost all cases we do not support pointers. The only exceptions are the ones shown in the Call Library Node configuration. For arrays, notice that if you want to return an array to LV, we have our own defined data types for this - read up on the CIN section for more information.
* If you want to return a pointer than LV just messages to other DLLs: No problem. Put the parameter to the routine as a pointer to integer (or a return value of type int). Thus your pointer is an integer as far as LV is concerned. When you pass it to another DLL, we'll pass the exact same value to the DLL - thus the pointer is never modified or the data touched.
Did this help?
Message Edited by Lycangeek on 08-10-2005 02:12 PM
Brian Tyler
http://detritus.blogs.com/lycangeek

Similar Messages

  • How do I pass a 1D LabView array as a pointer to an array in a C DLL?

    Hello,
    I am trying to pass a 1D Labview array of DOUBLE to a C DLL which is expecting a pointer to an array of DOUBLE.  I have read that LabView stores arrays as a pointer to a pointer and that the first element of a LabView array is actually the size of the array.  So I think my question is then how do I dereference the first pointer and pass in a pointer which points to the second element in the array?    
    Any thoughts out there?
    Thanks!

    Hi justyou,
    There are many, many resources on this topic, so I will guide you to the two most useful ones:
    The "Call DLL.vi" example that ships with LabVIEW explains how to use almost any data type when executing DLLs. The "Call DLL.vi" can be found by browsing the Example Finder.
    Integrating DLLs. This page is the portal for DLL interation related resources. Read the tutorials and try the examples...
    This should give you some ideas.
    Have fun!
    - Philip Courtois, Thinkbot Solutions

  • How to view C/C++   pointer as an array in Xcode GUI debugger?

    How to view C/C++ pointer as an array in Xcode GUI debugger?

    A similar question was asked recently regarding strings. You cannot pass pointers in LabVIEW as you do in C. You can pass an array to a DLL, but that means you would need to write a wrapper DLL. Be sure to read the section in the LabVIEW Help on calling code from text-based languages and also take a look at the "Call DLL" example that ships with LabVIEW  - it contains many examples of how to deal with various datatypes.

  • Converting data pointed to by a pointer into an array

    The vi I use returns a pointer to a block of data. The data are
    unsigned 16-bit integers. Without using a for..do loop, how do I
    convert the data into an array for input into an intensity graph?
    (Note that I presently use a for...do loop that works by incrementing
    the pointer by 2 bytes each time. But it  takes much time and I
    want to eliminate using a loop in labview. I suspect built-in
    functions/using DLLs would be much faster. But I do not know how to go
    about doing it.)
    Thank you for your help.

    Hi Balakumar,
    > The vi I use returns a pointer to a block of data.
    If by "pointer" you mean a memory address, then I think you're DLL idea is right on track.  You could efficiently cast (sort of) the pointer into an array.
    The attached .zip contains some VIs that may give you some ideas.  In LabVIEW, open the application builder and load CVTDLL.bld.  It compiles CVTDLL.vi into CVTDLL.dll.  CVTDLLCaller calls the DLL - passing it the pointer and returning an array.  The magic will happen in the way the pointer parameter is passed from the VI to the DLL.  I think we need the CLF to think it's supposed to be passing a U32 value, where the DLL thinks it receiving a pointer to an array.  Then it's just a matter of passing the data back out.  There are a bunch of forum contributors who could get this right the first try - "smercurio" and "RolfK" come to mind.
    I hope this isn't yet another case where I'm way off track!
    cheers.
    When they give imbeciles handicap-parking, I won't have so far to walk!
    Attachments:
    CVTDLL.zip ‏20 KB

  • If i load 1GB file in labview array, it shows memory full. How tom handle it?

    if i load 1GB file in labview array, it shows memory full. How tom handle it?

    Don't read it all at once.  Just read the parts you need when you need it.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How do I view a c pointer as an array?

    I feel a bit stupid asking something that I think should be so simple, but I can't seem to make xcode show the values of a pointer as an array of elements of that type. Can someone tell me how to view "data" in this example as an array[50] of TestType?
    typedef struct {
    int x;
    float y;
    } TestType;
    int
    main(int argc, char * const argv[]) {
    TestType *data = new TestType[50];
    // I want to look at the data here....
    return 0;
    Thanks for your time,
    Hunter

    I had originally thought that Custom Data Formatters might be the solution for typecasting my views in the gui debugger. I wasn't quite able to get what I wanted and quit trying further once I understood that they apply by type. The next think I knew, for example, every int* was trying to print itself out as a int[N] and not just the particular int* that I had actually allocated for that purpose. What I'm really looking for is something to tell the debugger: "This variable right here... it's actually used as a THIS, now show me it just like you would show any THIS."
    In retrospect, perhaps I'm being a bit spoiled. grin DISPLAY and PRINT work fine from the command-line. I just thought that with this beautiful interface there had to be some straightforward way to typecast the visualization of the data. Even DDD and Insight allowed this and that's 10ish year old technology.
    - Hunter
    MacBook Pro   Mac OS X (10.4.6)   2.0 GHz, 2 GB RAM, 100 GB HD

  • Selecting points in an array

    HI 
    I generate a series of sine waves and store the values as an array, next i need to select only those points in the array that correspond to the amplitude of the sine wave i specify. Could anybody suggest how i go about it?

    Thank you for the replies. In the vi you modified GerdW i have now included an array(array 3 in vi) such that i can obtain all the points at which the amplitudes were at any specified value, i.e at the max/min i should have 6 points and at any other amplitude i should have 12 points that have the same amplitude. For the abritrary values i have set,  the InRange function seems to be coercing all the points(1000 in this case) to one amplitude, as seen in array3.
    I am sorry i have not mentioned why i intend on doing this. I generate a 3D spiral that i need to overlay on a stack of 2D images of fixed z increments, so for every image i will have one or 2 points where the trajectory intersects each image, i need to determine the corresponding (x,y) for each of the points such that i can overlay them on the image.
    Attachments:
    overlaying trajectory on image.vi ‏20 KB

  • Pointer Manipulation: Wrap Around/Rollover/Rotation of LabVIEW Arrays and Waveforms???

    I know we can't use pointers in LabVIEW, but I was wondering if there's any way we can do wrap-around [or "rollover," or "rotation"] of Array [or Waveform] values without having to make copies of the Array [or Waveform]?
    For instance, suppose I'm reading one second's worth of data into a five second buffer. After the first five seconds, I've got
    1st (1/5)th: 1st second's worth of data
    2nd (1/5)th: 2nd second's worth of data
    3rd (1/5)th: 3rd second's worth of data
    4th (1/5)th: 4th second's worth of data
    5th (1/5)th: 5th second's worth of data
    Now I read the sixth second's worth of data, and overwrite the [original] first second, so that I have
    1st (1/5)th: 6th second's worth of data
    2nd (1/5)th: 2nd second's worth of data
    3rd (1/5)th: 3rd second's worth of data
    4th (1/5)th: 4th second's worth of data
    5th (1/5)th: 5th second's worth of data
    and in C, or C++, I'd just move the pointer up to the second (1/5)th of data, and start from there.
    The LabVIEW Complex FFT is another place where this would be really useful. The Help File for the Complex FFT is in
    Help | VI and Function Reference | Analyze VIs | Signal Processing VIs | Frequency Domain VIs | Complex FFT.
    If you read the Help File, you see that LabVIEW returns an FFT with values in the range
    [0, 2n - 1)
    rather than the standard
    [-n, n - 1)
    i.e. LabVIEW takes the negative frequencies and tacks them on at the end, after the positive frequencies.
    I'd like to be able to view my FFTs with the negative frequencies where they're supposed to be [i.e to the left of zero], and this would be SO easy if I could just move the underlying data pointer of the Waveform forward to the halfway point.
    But, of course, in LabVIEW, I don't have pointers, so I was wondering: Are there any built-in VIs for Array [or Waveform] manipulation that will perform this sort of wrap-around [or "rollover," or "rotation"] of the data? If so, I couldn't find them. Ideally, such a VI would have two inputs: {old Array, new starting point}, and one output: {new Array}. Similarly with Waveforms, only you'd need to manipulate t0 as well.
    Or do I have to copy the entire data set to a new Array [or Waveform] each time I reach the end of the buffer?
    Thanks!

    > Ideally, such a VI would have two inputs: {old Array, new starting point}, and one output: {new Array}.
    Have a look at "rotate 1D array" in the array palette (second row, fourth column).
    (Sorry, I dont use waveform data).
    LabVIEW Champion . Do more with less code and in less time .

  • How to get data from a pointer to an array using dlportio?

    I use DLPORTIO.DLL to access the parallel port on a WinXP. The purpose is to read data coming from an fpga.
    The transfer rate is quite high (more than 500kB/s).
    DLPORTIO.DLL can buffer data from the parallel port.
    I would like to use this fonctionality to speed up the data transfer by ready 16 x 8 bits that have been buffered. I get the pointer to the element from the dll. 8bits means U8 in Labview and, of course, 16 => U16 and 32bits => U32. But what to connect when I want 128bits??? How to use the pointer cominf from the dll and say to Labview it is the pointer to the first element of my 16 element array??
    Thanks to all
    Dai Tran Duy
    Dai
    LV 7.1 - WIN XP - RT - FP
    Attachments:
    dlportio.zip ‏852 KB

    LabVIEW does not have a 128 bit numeric so you will need to create a work around of sorts. What I would suggest is creating some wrapper dll functions. These funcitons would take say an array of U8s from LabVIEW, convert them into your 128 bit number and then call your dll with that.
    In addition take a look at the manual on exteranl code in LabVIEW, Using External Code in LabVIEW, which discusses how to pass arrays to a dll. In addition there is a shipping example in LabVIEW 7.0 that shows how to pass all sorts of LabVIEW and C data types. The example even includes C code snipits.

  • Surface analysis (Roughness and peak points)using 2D array

    I am  having a 2D array of complex numbers as a result of some kind of transformation of an original image. I need to find surface characteristics like roughness, peak points  from these values. How is it possible? Can anyone suggest a method or somethin like that?
    thnx
    Nghtcwrlr
    ********************Kudos are alwayzz Welcome !! ******************

    Hello Bernd
    I am using LabVIEW 8.2. I have already seen the algorith to detect edges using convolution. But i need to find some kind of property between fourier coefficient and high edges. I would rather like not to use any development modules like  Vision Development Module .
    Thnxx
    Nghtcwrlr
    ********************Kudos are alwayzz Welcome !! ******************

  • LabVIEW array performance: Two loops operating on the same massive array

    Yes there has been a lot said and left unsaid about LabVIEW performance in the past - but I have to ask the following:
    Is it possible to have two seperate while loops act on the same data without making copies?
    Say I have a 1GB array of doubles which I have wired to a shift register on one loop.  With a little bit of effort (by using in-place and chasing the dots a bit) it would be possible to operate on that data inside that loop without making copies.
    But what if I need to also access that same array in a different loop (which is running at a different rate).  I basically need two loops' shift registers to point to the same data.  At the moment the only way I can manage this is to use DLL calls which destroys dataflow but al least makes no copies.  It also means I cannot use LabVIEW code but have to resort to C coding.   
    Data corruption is no issue as the two loops, at any instant, operate in different locations of the array.
    Any smart ideas that will work?

    drclaw wrote:
    Hi AnthonV,
    A Functional Global approach might suit your needs. This will allow you to keep you data in a shift register, but access/modify parts of the data from other VIs or loops.
    Another option is to use a single element queue to store the array to achieve a similar result.
    Both these options and more techniques are located at
    http://zone.ni.com/devzone/cda/tut/p/id/3625#toc0 
    Hope that helps 
    Good suggestion. Functional Globals also go by the name "Action Engine" as I discuss in this Nugget on Action Engines.
    Put all of your number crunching code inside appropriately named Actions of the AE and that way all of the work CAN be done "in-place".
    Have fun! 
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How to access data via pointer under LabVIEW

    我們的產品(WebCam)有提供ActiveX Driver供客戶自行開發程式;但是當客戶呼叫Method(via Invoke Node)時卻無法將Variant型態的資料透過Variant to Data還原, 這個Variant實際上是一個指向int far *的指標; 該如何在LabVIEW中使用指標 

    ni.com>>search>>labview pointer
    http://zone.ni.com/devzone/cda/epd/p/id/3794
    labview>>help>>find examples>>search>>DLL>>call DLLs.vi

  • How to pass a pointer in labview library call function by using dll programmed in Labwindows​?

    Hi,
    I'm trying to interface a camera with Labview.  However, the camera can only be programmed by C, so I'm using Labwindow CVI.
    I need to pass a camera handle from one function to another, eg. from a opencamera function to setparameter function.  
    /* Load the Qcam driver and Open the First Camera */
    void DLLEXPORT LoadDriverAndOpenCamera()
    QCam_CamListItem cameraList[10];
    unsigned long cameraListLength=sizeof(cameraList)/sizeof(cameraL​ist[0]);
    //load the driver
    QCam_LoadDriver();
    //get a list of the cameras
    QCam_ListCameras(cameraList,&cameraListLength);
    //listLength is now the number of cameras available
    QCam_Handle hCam;
    //Open the first camera in the list
    QCam_OpenCamera(cameraList[0].cameraId, &hCam);
    Apparently, caemraId is an unsigned long (unsigned 32-bit in Labview 2012 32-bit? ) and QCam_Handle is defined as void*, so it's a pointer that points to an unsigned 32-bit.
    When I only use C for programming, I can pass hCam variable to other functions as long as it's declared as global variable.  Ex, the next function can be void SetParameter(QCam_Handle hCam).  However, here I'm trying to make a dll by Labwindows/CVI and then call LoadDriverAndOpenCamera() function through library call in Labview.  
    My question is:  How can I pass hCam to other functions in the same dll?  Do I have to add paramter to the function? For example:
    void DLLEXPORT LoadDriverAndOpenCamera(unsigned long cameraId, QCam_Handle* cameraHandle)
    And then add two lines:
    cameraId=cameraList[0].cameraId;
    cameraHandle=hCam;
    into the function?  Then I can pass cameraHandle out?  However, hCam will still have void* type.
    Even if that's the case, how can I set up library call node on Labview?  In the arg parameter set up, I don't see pointers?  It seems I cannot set up an output node to be a pointer that points to a unsigned long.
    Thank you very much for your help!
    Best,
    Charles
    Solved!
    Go to Solution.

    Hello Charles, 
    I noticed you posted a similar question here. do you have any further questions about using the call library function node? 
    Haley N
    Applications Engineer
    National Instruments

  • Output labview array to LED grid using DI/O on Elvis II??

    I have been working on a project. I am attempting to use the DI/O on the ELvis II board to power an 10x6 LED grid similar 
    to the common-row cathode design here
    http://www.appelsiini.net/2011/how-does-led-matrix-work
    I have been attempting to generate block patterns using an array in labview, then somehow convert this array to show the block pattern on the grid. I was planning on using DI/O 0-5 to power the columns and DI/O 6-15 to power the rows. Is such a thing even possible? So far I have created a simple DAQ assistant to control the DI/O on the board and can control values that way. i was just interested in knowing if they can be controlled using a labview program.

    Generate digital pulse from your D I/O to control the relay. With Digital High State, the mechanical arrangement will connect the COMM to "NO" .... and you will get your programmable Ground. (in your case NC is not necessary I hope) 
    The device is not so costly. you can purchase 4-5 number with your pocket money only. And It must be available to your nearby Electronics Shop. Use 1 for each line.
    Attachments:
    Relay.PNG ‏8 KB

  • How to optimize the memory for a large labview array?

    I am running LabView on Windows XP with 4 Gb of RAM. The array is 51X256X256 complex numbers, but I want 300x256x256. The program runs out of memory when I use more than 51-53 arrays of 256X256. I do not know how to use the in place element structure to modify the vi below. The unbundled/ bundle structures do not present symmetry. Anyone can help me with this?  Thanks!
    Mariana
    Attachments:
    array3Dc.JPG ‏22 KB
    array3Dc_front.JPG ‏58 KB

    Norbert,
      The full data3Dc array takes about 15.5 MB and the data3Dc comp.vi takes 31 MB. The empty data3Dc comp.vi array takes only 18.2 kB. This array is a variable that modifies at each scanned wavelength. I have a scanning wavelengths software package. For one wavelength I record a hologram followed by the reconstruction of the object field (1x256x256). 3D optical fields are added all together to create a big 3D optical field (Nx256x256). The code data3Dc comp_1.vi is not the only one in the memory. This VI is a subvi for other codes. A few other examples are FFT, IFFT, filtering, phase matching, cross-section, calibration….I did not care about memory optimization until now. So, I want to scan more than 50 wavelengths. By now (N=50) I have to restart the LabView after each scanning, do the reconstruction of the fields, start the LabView again to see the results. I think the problem is caused by this VI that is a subvi for other codes. I already extended the memory to 3GB in boot.ini, but the thing is that I want also a small scanning time. It doesn’t work. Extending the memory to 3GB makes the OS slower than before. My question is how to modify this array (data3Dc) or the VI (data3Dc comp.vi) to access lesser memory. I have tried to attach the full VI but it tells me that it is too big. I attached the empty one.
      Thanks,
    Mariana
    Attachments:
    data3Dc comp.vi ‏19 KB

Maybe you are looking for

  • LSMW parent child?

    Hi Everyone , In LSMW , Header and Details file specification , If the header file has some records which do not have a corresponding record in the details file ...then Would LSMW program read those records from the header file ? I mean does LSMW rea

  • File Share does not appear as a Datasource!

    I have created a File System Repository and a Index - However when I try and select a data source on the Index I can't find the file share I created. I have set up the Folder as a Mounted Network folder! Hope someone can help!

  • How to temporarily disable Charm?

    Hi. We have scheduled a system upgrade of the Solution Manager machine, causing a downtime of two complete days. In these two days it must still be possible to develop and transport customizing/workbench content in the satellite system landscapes whi

  • Unistalling Trial Office 2010 Pro - Will this impact activated version of Office 2010 Home & Student

    I am running W7.  There is an expired Trial Version of Office 2010 Professional on this PC.  There is also an ACTIVATED license of Office 2010 Home & Student.  If I open Word, select Help, and click the "Unistall" option, I get a message that says ea

  • Flash newbie wants to know how to open a new browser

    Hello all! I'm a flash newbie who needs some help! I am building a flash website. To navigate within the site, i made buttons which use the "gotoandStop" behavior which takes the user to certain frames within the my Flash file timeline. However, I wa