LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW.exe - application error

Hi.

I'm trying to use CIN to up-down flip a two dimensional array passed from LabVIEW.  Everything seems to work fine when I run the .vi (flipper.vi).  However, when I run another .vi (save_data.vi) that uses the flipper subroutine, it crashes LabVIEW.

Specifically, I recieve a LabVIEW.exe - Application Error:

The instruction at x-location referenced memory at y-location. The memory could not be "read".

Now I understand that somewhere along the lines LabVIEW accesses corrupt memory, due to a lack of array initialization or something. Unfortunately, that's about all I understand.

I'm using LabVIEW 8.0. Here is my flipper CIN code:


/* CIN source file */

#include <extcode.h>

/* stubs for advanced CIN functions */

UseDefaultCINInit
UseDefaultCINDispose
UseDefaultCINAbort
UseDefaultCINLoad
UseDefaultCINUnload
UseDefaultCINSave

/* Typedefs */

typedef struct {
    int32 dimSizes[2];
    int16 Numeric[1];
    } TD1;
typedef TD1 **TD1Hdl;


extern "C"{
MgErr CINRun(TD1Hdl dataIn, TD1Hdl dataOut);
}


MgErr CINRun(TD1Hdl dataIn,
TD1Hdl dataOut)
    {

        int32 rowSize = (**dataIn).dimSizes[0]; // number of rows of data
        int32 colSize = (**dataIn).dimSizes[1];    // number of columns of data
        
        (**dataOut).dimSizes[0] = rowSize;
        (**dataOut).dimSizes[1] = colSize;
        
        // up-down flip of data
        int32 i, j, arrayIndex;

        for(i = 0; i < rowSize; i++)
        {
            for(j = 0; j < colSize; j++)
            {
                arrayIndex = colSize*i + j;
                (**dataOut).Numeric[arrayIndex] = (**dataIn).Numeric[arrayIndex];
        
            }
        }
        
    return noErr;
    }


Let me know if you have any ideas on how to possibly initialize the data that I'm passing into the CIN.
Hopefully this makes some sense. Thanks,

0 Kudos
Message 1 of 3
(2,343 Views)

Hi, mrod,

The destination array should be resized before writing values with NumericArrayResize function:

The code above should work without troubles (hopefully).

best regards,
Andrey.

0 Kudos
Message 2 of 3
(2,323 Views)
Hi, Andrey.

The NumericArrayResize fixed the error I was getting. Thanks so much.

best regards.
0 Kudos
Message 3 of 3
(2,294 Views)