Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Proper use of ring acquisition?

Hi All,

I've got a imgSnap acquisition working with my PCIe-1433 framegrabber, however, I require far more speed so am attempting to use ring buffers. I have followed the examples llring.c and hlring.c, however I've found that they both use imgSessionExamineBuffer(...). The NI-IMAQ Help shows that for high level ring functions, you can use imgSessionStatus to get the index of the most recent valid buffer (see fig1 attached). However, if I call imgSessionStatus in my acquisition loop, it indicates that a session is acquiring (as expected) but that the last valid index is 4294967295. I think this is incorrect because I have set my ring buffer to have a size of 10000, and also because that supposed index is equal to max(uInt32). If I pass this index to imgSessionExamineBuffer() anyway, then I get the error code -1074397014, which means that the buffer has been overwritten. I'm a little confused, as I would have thought that if the ring buffer has been setup correctly, the index value could never be beyond the length of my ring buffer. At the moment I am using default internal triggering, I don't know what speed this triggers at, but my acquisition loop is quite fast (20 or 30 us) so I would be surprised if the entire ring buffer fills faster than I can grab a single frame.

My setup essentially looks like this:

//thread 1:
ReportError(imgInterfaceOpen("img0", &interface_id_));
ReportError(imgSessionOpen(interface_id_, &session_id_));
ReportError(imgRingSetup(session_id_, nr_of_buffers_, (void**)image_buffers_, 0, FALSE));

//thread 2 (gui button, guaranteed to run after thread 1):
ReportError(imgSessionStartAcquisition(session_id_));

//thread 3, launched by thread 2
while(acquire){
    ReportError(imgSessionStatus(session_id_, status_ptr, buffer_index_ptr));
    ReportError(imgSessionExamineBuffer2(session_id_, buffer_index, &current_buffer_nr, &buffer_addr));
    //process the data acquired 
}

Can anyone provide any insight as to a) why my buffers are filling up past the ring buffer end, or b) why is the frame being overwritten?

Thanks very much for your time

Best Regards,

Aaron

0 Kudos
Message 1 of 1
(1,864 Views)