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;
...
}