Jump to content
  • 0

mcc172_a_in_scan_status does not always return samples_per_channel


Martin Wollatz

Question

The example programs read with READ_ALL_AVAILABLE. For me, this meant that fragments of the 4-byte variables were also read. That's why I want to determine beforehand how many samples are in the buffer. However, the mcc172_a_in_scan_status function shows strange behavior. If it has not yet been read with mcc172_a_in_scan_read, mcc172_a_in_scan_status always reads a 0. Only when at least 1 value has been read will the number of values be displayed correctly. Am I doing something wrong?
 

do
    {
        // Since the read_request_size is set to -1 (READ_ALL_AVAILABLE), this
        // function returns immediately with whatever samples are available (up
        // to user_buffer_size) and the timeout parameter is ignored.
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        result = mcc172_a_in_scan_status(address, &scan_status, &samples_to_read);
        STOP_ON_ERROR(result);

        printf("read %u status %i\r\n", samples_to_read, scan_status);
        if (samples_to_read == 0)samples_to_read=1;  //if i don´t have this, nothing will be read at all...

        result = mcc172_a_in_scan_read(address, &read_status, samples_to_read, timeout, read_buf, user_buffer_size, &samples_read_per_channel);
        STOP_ON_ERROR(result);

        if (read_status & STATUS_HW_OVERRUN)
        {
            printf("\n\nHardware overrun\n");
            break;
        }
        else if (read_status & STATUS_BUFFER_OVERRUN)
        {
            printf("\n\nBuffer overrun\n");
            break;
        }

        total_samples_read += samples_read_per_channel;

...

}

 

 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Use mcc172_a_in_scan_start first to start the acquisition, then use mcc172_a_in_scan_status to determine the number of samples in the buffer. Study the attached C program. It requests 256 samples and displays the loop execution time, samples read, channel 0, channel 1, and the number of samples left in the buffer after the read. 

continuous_scan2.c

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...