in CodeSnippets/Peripherals/ADC/AdvancedFunctions/advanced_functions.c [283:308]
static int GetSampleBitCount(int adcControllerFd, ADC_ChannelId channelId,
struct iio_ioctl_chan_spec_buffer *channelSpecBuffer)
{
// Buffer to hold decimal representation of 4-byte integer value and null terminator.
char dataBuffer[12];
int res = GetExtInfo(adcControllerFd, channelId,
(unsigned int)GetPropertyIndex(channelSpecBuffer->channel, "current_bits"),
dataBuffer, sizeof(dataBuffer));
if (res < 0) {
Log_Debug("ERROR: Failed to retrieve extended channel information for channelId = %u.\n",
channelId);
return -1;
}
if (sizeof(dataBuffer) <= strnlen(dataBuffer, sizeof(dataBuffer))) {
Log_Debug("ERROR: Extended channel information received is invalid for channelId = %d.\n",
channelId);
return -1;
}
int numberOfBits = atoi(dataBuffer);
return numberOfBits;
}