Added MCS table string serializer

This commit is contained in:
Xavier Arteaga 2020-11-06 19:22:50 +01:00 committed by Andre Puschmann
parent 794d1b5c4b
commit 3464dd3c0d
2 changed files with 46 additions and 1 deletions

View File

@ -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

View File

@ -20,6 +20,7 @@
*/
#include "srslte/phy/common/phy_common_nr.h"
#include <string.h>
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;
}