rf_imp: fail opening RF altogether if specified device fails to open

we've had a few runs in the CI where opening the specified RF device
failed but the eNB/UE still continued to run, just picking the next available
run. This led to false-positive tests.

The policy should be that whenever the user specified a RF device to
be openend, and this device fails, the whole process should fail and
the application should exit.

The auto-detection mode is still available but only if no device name
is specified at all.
master
Andre Puschmann 3 years ago committed by Xavier Arteaga
parent c9478a4306
commit e563e5918e

@ -93,32 +93,33 @@ const char* srsran_rf_get_devname(srsran_rf_t* rf)
int srsran_rf_open_devname(srsran_rf_t* rf, const char* devname, char* args, uint32_t nof_channels) int srsran_rf_open_devname(srsran_rf_t* rf, const char* devname, char* args, uint32_t nof_channels)
{ {
rf->thread_gain_run = false; rf->thread_gain_run = false;
/* Try to open the device if name is provided */
if (devname) { // Try to open the device if name is provided
if (devname[0] != '\0') { if (devname && devname[0] != '\0') {
int i = 0; int i = 0;
while (available_devices[i] != NULL) { while (available_devices[i] != NULL) {
if (!strcasecmp(available_devices[i]->name, devname)) { if (!strcasecmp(available_devices[i]->name, devname)) {
rf->dev = available_devices[i]; rf->dev = available_devices[i];
return available_devices[i]->srsran_rf_open_multi(args, &rf->handler, nof_channels); return available_devices[i]->srsran_rf_open_multi(args, &rf->handler, nof_channels);
}
i++;
} }
printf("Device %s not found. Switching to auto mode\n", devname); i++;
} }
} // provided device not found, abort
return SRSRAN_ERROR;
/* If in auto mode or provided device not found, try to open in order of apperance in available_devices[] array */ } else {
int i = 0; // auto-mode, try to open in order of apperance in available_devices[] array
while (available_devices[i] != NULL) { int i = 0;
if (!available_devices[i]->srsran_rf_open_multi(args, &rf->handler, nof_channels)) { while (available_devices[i] != NULL) {
rf->dev = available_devices[i]; if (!available_devices[i]->srsran_rf_open_multi(args, &rf->handler, nof_channels)) {
return 0; rf->dev = available_devices[i];
return SRSRAN_SUCCESS;
}
i++;
} }
i++;
} }
ERROR("No compatible RF frontend found"); ERROR("No compatible RF frontend found");
return -1; return SRSRAN_ERROR;
} }
const char* srsran_rf_name(srsran_rf_t* rf) const char* srsran_rf_name(srsran_rf_t* rf)

Loading…
Cancel
Save