From e563e5918e69fda143272dec14f0f872e4cf3d63 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Tue, 14 Sep 2021 15:30:08 +0200 Subject: [PATCH] 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. --- lib/src/phy/rf/rf_imp.c | 43 +++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/lib/src/phy/rf/rf_imp.c b/lib/src/phy/rf/rf_imp.c index 9a6d25966..bccfe5758 100644 --- a/lib/src/phy/rf/rf_imp.c +++ b/lib/src/phy/rf/rf_imp.c @@ -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) { rf->thread_gain_run = false; - /* Try to open the device if name is provided */ - if (devname) { - if (devname[0] != '\0') { - int i = 0; - while (available_devices[i] != NULL) { - if (!strcasecmp(available_devices[i]->name, devname)) { - rf->dev = available_devices[i]; - return available_devices[i]->srsran_rf_open_multi(args, &rf->handler, nof_channels); - } - i++; + + // Try to open the device if name is provided + if (devname && devname[0] != '\0') { + int i = 0; + while (available_devices[i] != NULL) { + if (!strcasecmp(available_devices[i]->name, devname)) { + rf->dev = available_devices[i]; + return available_devices[i]->srsran_rf_open_multi(args, &rf->handler, nof_channels); } - printf("Device %s not found. Switching to auto mode\n", devname); + i++; } - } - - /* If in auto mode or provided device not found, try to open in order of apperance in available_devices[] array */ - int i = 0; - while (available_devices[i] != NULL) { - if (!available_devices[i]->srsran_rf_open_multi(args, &rf->handler, nof_channels)) { - rf->dev = available_devices[i]; - return 0; + // provided device not found, abort + return SRSRAN_ERROR; + } else { + // auto-mode, try to open in order of apperance in available_devices[] array + int i = 0; + while (available_devices[i] != NULL) { + if (!available_devices[i]->srsran_rf_open_multi(args, &rf->handler, nof_channels)) { + rf->dev = available_devices[i]; + return SRSRAN_SUCCESS; + } + i++; } - i++; } + ERROR("No compatible RF frontend found"); - return -1; + return SRSRAN_ERROR; } const char* srsran_rf_name(srsran_rf_t* rf)