diff --git a/lib/include/srslte/phy/common/phy_common_nr.h b/lib/include/srslte/phy/common/phy_common_nr.h index a8c77226a..58300b6a5 100644 --- a/lib/include/srslte/phy/common/phy_common_nr.h +++ b/lib/include/srslte/phy/common/phy_common_nr.h @@ -136,7 +136,8 @@ typedef enum SRSLTE_API { typedef enum SRSLTE_API { srslte_mcs_table_64qam = 0, srslte_mcs_table_256qam, - srslte_mcs_table_qam64LowSE + srslte_mcs_table_qam64LowSE, + srslte_mcs_table_N } srslte_mcs_table_t; /** @@ -281,6 +282,20 @@ SRSLTE_API uint32_t srslte_coreset_get_bw(const srslte_coreset_t* coreset); */ SRSLTE_API uint32_t srslte_coreset_get_sz(const srslte_coreset_t* coreset); +/** + * @brief Get the MCS table string + * @param mcs_table MCS table value + * @return Constant string with the MCS table name + */ +SRSLTE_API const char* srslte_mcs_table_to_str(srslte_mcs_table_t mcs_table); + +/** + * @brief Get the MCS table value from a string + * @param str Points to a given string + * @return The MCS table value + */ +SRSLTE_API srslte_mcs_table_t srslte_mcs_table_from_str(const char* str); + #ifdef __cplusplus } #endif diff --git a/lib/src/phy/common/phy_common_nr.c b/lib/src/phy/common/phy_common_nr.c index 0be023b8d..70938fa6a 100644 --- a/lib/src/phy/common/phy_common_nr.c +++ b/lib/src/phy/common/phy_common_nr.c @@ -20,6 +20,7 @@ */ #include "srslte/phy/common/phy_common_nr.h" +#include uint32_t srslte_coreset_get_bw(const srslte_coreset_t* coreset) { @@ -42,3 +43,32 @@ uint32_t srslte_coreset_get_sz(const srslte_coreset_t* coreset) // Returns the number of resource elements in time and frequency domains return srslte_coreset_get_bw(coreset) * SRSLTE_NRE * coreset->duration; } + +const char* srslte_mcs_table_to_str(srslte_mcs_table_t mcs_table) +{ + switch (mcs_table) { + + case srslte_mcs_table_64qam: + return "64qam"; + case srslte_mcs_table_256qam: + return "256qam"; + case srslte_mcs_table_qam64LowSE: + return "qam64LowSE"; + default: + return "undefined"; + } +} + +srslte_mcs_table_t srslte_mcs_table_from_str(const char* str) +{ + if (strcmp(str, "64qam") == 0) { + return srslte_mcs_table_64qam; + } + if (strcmp(str, "256qam") == 0) { + return srslte_mcs_table_256qam; + } + if (strcmp(str, "qam64LowSE") == 0) { + return srslte_mcs_table_qam64LowSE; + } + return srslte_mcs_table_N; +}