Bugfix: Made Uldaq sample rate check depending on actually provided sample rates

This commit is contained in:
Anne de Jong 2023-04-18 11:09:01 +02:00
parent f1348ede80
commit fb9920d00a
3 changed files with 10 additions and 5 deletions

View File

@ -67,10 +67,7 @@ void fillUlDaqDeviceInfo(DeviceInfoList &devinfolist) {
DataTypeDescriptor::DataType::dtype_fl64);
devinfo.prefDataTypeIndex = 0;
devinfo.availableSampleRates = {8000, 10000, 11025, 16000, 20000,
22050, 24000, 32000, 44056, 44100,
47250, 48000, 50000, 50400, 51000};
devinfo.availableSampleRates = ULDAQ_SAMPLERATES;
devinfo.prefSampleRateIndex = 11;
devinfo.availableFramesPerBlock = {512, 1024, 2048, 4096, 8192};

View File

@ -70,7 +70,7 @@ DT9837A::DT9837A(const DeviceInfo &devinfo, const DaqConfiguration &config)
throw rte("Unsensible number of samples per block chosen");
}
if (samplerate() < 10000 || samplerate() > 51000) {
if (samplerate() < ULDAQ_SAMPLERATES.at(0) || samplerate() > ULDAQ_SAMPLERATES.at(ULDAQ_SAMPLERATES.size()-1)) {
throw rte("Invalid sample rate");
}

View File

@ -14,6 +14,14 @@ using std::cerr;
using std::endl;
using rte = std::runtime_error;
/**
* @brief List of available sampling frequencies for DT9837A
*/
const std::vector<d> ULDAQ_SAMPLERATES = {8000, 10000, 11025, 16000, 20000,
22050, 24000, 32000, 44056, 44100,
47250, 48000, 50000, 50400, 51000};
/**
* @brief UlDaq-specific device information. Adds a copy of the underlying
* DaqDeDaqDeviceDescriptor.