Added subcarrier spacing parsing from string

master
Xavier Arteaga 4 years ago committed by Xavier Arteaga
parent b69057b76e
commit f9aafd00a7

@ -594,6 +594,13 @@ SRSRAN_API int srsran_carrier_to_cell(const srsran_carrier_nr_t* carrier, srsran
*/
SRSRAN_API uint32_t srsran_csi_meas_info(const srsran_csi_trs_measurements_t* meas, char* str, uint32_t str_len);
/**
* @brief Converts a given string into a subcarrier spacing
* @param str Provides the string
* @return A valid subcarrier if the string is valid, srsran_subcarrier_spacing_invalid otherwise
*/
SRSRAN_API srsran_subcarrier_spacing_t srsran_subcarrier_spacing_from_str(const char* str);
#ifdef __cplusplus
}
#endif

@ -12,6 +12,7 @@
#include "srsran/phy/common/phy_common_nr.h"
#include "srsran/phy/utils/vector.h"
#include <stdlib.h>
#include <string.h>
const char* srsran_rnti_type_str(srsran_rnti_type_t rnti_type)
@ -321,3 +322,32 @@ uint32_t srsran_csi_meas_info(const srsran_csi_trs_measurements_t* meas, char* s
meas->cfo_hz,
meas->delay_us);
}
srsran_subcarrier_spacing_t srsran_subcarrier_spacing_from_str(const char* str)
{
if (str == NULL) {
return srsran_subcarrier_spacing_invalid;
}
uint32_t scs = (uint32_t)roundf(strtof(str, NULL));
switch (scs) {
case 15:
case 15000:
return srsran_subcarrier_spacing_15kHz;
case 30:
case 30000:
return srsran_subcarrier_spacing_30kHz;
case 60:
case 60000:
return srsran_subcarrier_spacing_60kHz;
case 120:
case 120000:
return srsran_subcarrier_spacing_120kHz;
case 240:
case 240000:
return srsran_subcarrier_spacing_240kHz;
default:; // Do nothing
}
return srsran_subcarrier_spacing_invalid;
}

Loading…
Cancel
Save