LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Out-of-bounds pointer argument (past end of memory block).

Hey guys,

 

  I'm trying to run a modified Acq-IntClk.C and got the following error:

 "FATAL RUN-TIME ERROR:   "Acq-IntClk.c", line 155, col 29, thread id 0x00001564:   Out-of-bounds pointer argument (past end of memory block)."

here is the segment that gives me error:

	PlotY(panel,PANEL_GRAPH,&(data[numRead]),numRead,VAL_DOUBLE,VAL_THIN_LINE,VAL_EMPTY_SQUARE,VAL_SOLID,1,plotColors[1%12]);

&(data[numRead]) is the problem

 i did some printfs:

											printf("sizeof(data):%d, numRead: %d, address: %d",sizeof(data),numRead,&(data[numRead]));

 and got:

sizeof(data):4, numRead: 80000, address: 51233856

 

the data array is carried over from

 

RandomGen(taskHandle,sampsPerChan,10.0,DAQmx_Val_GroupByChannel,data,sampsPerChan*numChannels,&numRead,NULL);
int32 RandomGen (TaskHandle taskHandle, int32 samplePerChannel, float64 timeout,bool32 fillMode, float64 *readArray,uInt32 arraySize, int32 *samplesPerChannelRead, bool32 *reserved){
int i;
double min = GblDataLow[taskHandle];
double max = GblDataHigh[taskHandle];
if (GblReadyForNiData[taskHandle]){
//for (i = 0; i < arraySize; i++)
for (i = 0; i < GblArraySize[taskHandle]; i++)
readArray[i] = Random(min, max);
*samplesPerChannelRead = arraySize;
}else{
*samplesPerChannelRead = 0;
}
return 0;
}

 

 

what is wrong with data here? RandomGen basically creates random data points to emulate DAQmxReadAnalogF64 and allows for Acq-IntClk to graph points as if the data came from some instrument.

 

thanks!

0 Kudos
Message 1 of 7
(4,016 Views)

I think the problem is that you're passing a pointer to the end of your data array to the plotting function.  The function is expecting a pointer to the beginning of the data array.  I think this is what you should be doing:

 

PlotY(panel,PANEL_GRAPH,&(data[0]),numRead,VAL_DOUBLE,VAL_THIN_LINE,VAL_EMPTY_SQUARE,VAL_SOLID,1,plotColors[1%12]);

 

 or more simply:

PlotY(panel,PANEL_GRAPH,data,numRead,VAL_DOUBLE,VAL_THIN_LINE,VAL_EMPTY_SQUARE,VAL_SOLID,1,plotColors[1%12]);

 

 

Message 2 of 7
(4,010 Views)

that fixed the error, but i'm getting a pretty weird looking plot. It's just a flat green line, seems like nothing is being plotted. This is probably since I simplified that line down and took it out of a loop. originally its:

if( numRead>0 )
   for(i=0;i<numChannels;i++)
PlotY(panel,PANEL_GRAPH,&(data[i*numRead]),numRead,VAL_DOUBLE,VAL_THIN_LINE,VAL_EMPTY_SQUARE,VAL_SOLID,1,plotColors[i%12]);

 does that change anything?

numChannels=8

0 Kudos
Message 3 of 7
(4,007 Views)

note that this line of code is taken from the example code, so i would assume that the PlotY line is correct

0 Kudos
Message 4 of 7
(4,001 Views)

The syntax for PlotY is correct.  I guess my question would be if there is any values in the data array?  Without knowing the values of some of the parameters in that RandomGen function I would guess that perhaps it's not filling the array.

 

As for the loop thing, it looks like it's looping through the array and plotting it in chunks, presumably because the data array is actually several measurements (of lengeth numRead) stiched together.  

0 Kudos
Message 5 of 7
(3,997 Views)

yea i just checked, the data array has values ranging from minVal to maxVal. I guess it just comes down to me now really knowing how to PlotY. I have the data and it just doesn't seem to cooperate with me. Numchannel is actually 80 so the data array has 80 elements.

0 Kudos
Message 6 of 7
(3,995 Views)

figured it out, numRead was too large. Thanks!

0 Kudos
Message 7 of 7
(3,990 Views)