Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

niHSDIO_FetchMultiRecordU32 memory issues

Solved!
Go to solution

My program is crashing when trying to use "niHSDIO_FetchMultiRecordU32" c-function.

 

I cannot find a pre-existing c example program that ships with the niHSDIO driver that uses this function.

 

here is the prototype from the niHSDIO.h include file:

 

   ViStatus _VI_FUNC niHSDIO_FetchMultiRecordU32 (
   ViSession vi,
   ViInt32 samplesToRead,
   ViInt32 maxTimeMilliseconds,
   ViInt32 startingRecord,
   ViInt32 numberOfRecords,
   ViUInt32 data[],
   struct niHSDIO_wfmInfo wfmInfo[]);

 

The help file says that this function "Fetches the data as a two-dimensional array of unsigned 32-bit integers and returns the number of samples read."  How exactly should I declare this "two-dimensional" array?

 

When I fetch a single record using this function I have no problems:

 

   niHSDIO_FetchMultiRecordU32(acq_vi, 524, 1000, 0, 1, &samp_data, &wfm_info);

 

But as soon as I try to fetch more than 1 record, my program crashes (and my exception handling routine won't even protect me):

 

   niHSDIO_FetchMultiRecordU32(acq_vi, 524, 1000, 0, 2, &samp_data, &wfm_info);

 

I'm confident that my acquisition did acquire more than 1 record but not confident in the layout of the memory for the "samp_data" variable.  I'm not using c, but accessing the DLL from another language.  I may have an error in my variable declaration for the waveform data array.

 

0 Kudos
Message 1 of 4
(3,426 Views)

I created a loop on niHSDIO_FetchMultiRecordU32, each time requesting the next record available but each time requesting only a single record be returned...  this works fine.

 

But it seems less efficient than figuring out what i've done wrong with declaring the "two-dimensioned data array" variable.

 

0 Kudos
Message 2 of 4
(3,425 Views)
Solution
Accepted by topic author broke
Hello broke,

The data array being passed into the function should be initialized to the number of samples * number of records you want to fetch. A good example of fetching multiple records is the DynamicAcquisitionOfMultipleRecords Example, found by  going to Start»All Programs»National Instruments»NI-HSDIO»Examples»c and navigating to Dynamic Acquisition\DynamicAcquisitionOfMultipleRecords.

If you have any questions about this example please let me know.

Regards,
Dan King

Message 3 of 4
(3,397 Views)

Thank you Dan_K.  I failed to find that example in my original browse through the examples.

 

As it turns out, my error was in the creation of the array of niHSDIO_wfmInfo needed to return waveform timing information... not the sample array.

 

0 Kudos
Message 4 of 4
(3,382 Views)