Added radio mode info in the recorder and fixed horrible code in the rigctl_server module

This commit is contained in:
AlexandreRouma
2023-09-06 05:38:00 +02:00
parent 4d0d14856b
commit 9c1361a8a9
3 changed files with 41 additions and 52 deletions

View File

@ -5,4 +5,5 @@ file(GLOB SRC "src/*.cpp")
include(${SDRPP_MODULE_CMAKE})
target_include_directories(recorder PRIVATE "src/")
target_include_directories(recorder PRIVATE "src/")
target_include_directories(recorder PRIVATE "../../decoder_modules/radio/src")

View File

@ -21,6 +21,7 @@
#include <core.h>
#include <utils/optionlist.h>
#include <utils/wav.h>
#include <radio_interface.h>
#define CONCAT(a, b) ((std::string(a) + b).c_str())
@ -437,6 +438,17 @@ private:
if (dbLvl.r > lvl.r) { lvl.r = dbLvl.r; }
}
std::map<int, const char*> radioModeToString = {
{ RADIO_IFACE_MODE_NFM, "NFM" },
{ RADIO_IFACE_MODE_WFM, "WFM" },
{ RADIO_IFACE_MODE_AM, "AM" },
{ RADIO_IFACE_MODE_DSB, "DSB" },
{ RADIO_IFACE_MODE_USB, "USB" },
{ RADIO_IFACE_MODE_CW, "CW" },
{ RADIO_IFACE_MODE_LSB, "LSB" },
{ RADIO_IFACE_MODE_RAW, "RAW" }
};
std::string genFileName(std::string templ, std::string type, std::string name) {
// Get data
time_t now = time(0);
@ -455,6 +467,7 @@ private:
char dayStr[128];
char monStr[128];
char yearStr[128];
const char* modeStr = "Unknown";
sprintf(freqStr, "%.0lfHz", freq);
sprintf(hourStr, "%02d", ltm->tm_hour);
sprintf(minStr, "%02d", ltm->tm_min);
@ -462,6 +475,11 @@ private:
sprintf(dayStr, "%02d", ltm->tm_mday);
sprintf(monStr, "%02d", ltm->tm_mon + 1);
sprintf(yearStr, "%02d", ltm->tm_year + 1900);
if (core::modComManager.getModuleName(name) == "radio") {
int mode;
core::modComManager.callInterface(name, RADIO_IFACE_CMD_GET_MODE, NULL, &mode);
modeStr = radioModeToString[mode];
}
// Replace in template
templ = std::regex_replace(templ, std::regex("\\$t"), type);
@ -472,6 +490,7 @@ private:
templ = std::regex_replace(templ, std::regex("\\$d"), dayStr);
templ = std::regex_replace(templ, std::regex("\\$M"), monStr);
templ = std::regex_replace(templ, std::regex("\\$y"), yearStr);
templ = std::regex_replace(templ, std::regex("\\$r"), modeStr);
return templ;
}