mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-01-26 01:34:43 +01:00
Added radio mode info in the recorder and fixed horrible code in the rigctl_server module
This commit is contained in:
parent
4d0d14856b
commit
9c1361a8a9
@ -5,4 +5,5 @@ file(GLOB SRC "src/*.cpp")
|
|||||||
|
|
||||||
include(${SDRPP_MODULE_CMAKE})
|
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")
|
@ -21,6 +21,7 @@
|
|||||||
#include <core.h>
|
#include <core.h>
|
||||||
#include <utils/optionlist.h>
|
#include <utils/optionlist.h>
|
||||||
#include <utils/wav.h>
|
#include <utils/wav.h>
|
||||||
|
#include <radio_interface.h>
|
||||||
|
|
||||||
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
||||||
|
|
||||||
@ -437,6 +438,17 @@ private:
|
|||||||
if (dbLvl.r > lvl.r) { lvl.r = dbLvl.r; }
|
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) {
|
std::string genFileName(std::string templ, std::string type, std::string name) {
|
||||||
// Get data
|
// Get data
|
||||||
time_t now = time(0);
|
time_t now = time(0);
|
||||||
@ -455,6 +467,7 @@ private:
|
|||||||
char dayStr[128];
|
char dayStr[128];
|
||||||
char monStr[128];
|
char monStr[128];
|
||||||
char yearStr[128];
|
char yearStr[128];
|
||||||
|
const char* modeStr = "Unknown";
|
||||||
sprintf(freqStr, "%.0lfHz", freq);
|
sprintf(freqStr, "%.0lfHz", freq);
|
||||||
sprintf(hourStr, "%02d", ltm->tm_hour);
|
sprintf(hourStr, "%02d", ltm->tm_hour);
|
||||||
sprintf(minStr, "%02d", ltm->tm_min);
|
sprintf(minStr, "%02d", ltm->tm_min);
|
||||||
@ -462,6 +475,11 @@ private:
|
|||||||
sprintf(dayStr, "%02d", ltm->tm_mday);
|
sprintf(dayStr, "%02d", ltm->tm_mday);
|
||||||
sprintf(monStr, "%02d", ltm->tm_mon + 1);
|
sprintf(monStr, "%02d", ltm->tm_mon + 1);
|
||||||
sprintf(yearStr, "%02d", ltm->tm_year + 1900);
|
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
|
// Replace in template
|
||||||
templ = std::regex_replace(templ, std::regex("\\$t"), type);
|
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("\\$d"), dayStr);
|
||||||
templ = std::regex_replace(templ, std::regex("\\$M"), monStr);
|
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("\\$y"), yearStr);
|
||||||
|
templ = std::regex_replace(templ, std::regex("\\$r"), modeStr);
|
||||||
return templ;
|
return templ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,6 +333,17 @@ private:
|
|||||||
_this->client->readAsync(1024, _this->dataBuf, dataHandler, _this, false);
|
_this->client->readAsync(1024, _this->dataBuf, dataHandler, _this, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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" }
|
||||||
|
};
|
||||||
|
|
||||||
void commandHandler(std::string cmd) {
|
void commandHandler(std::string cmd) {
|
||||||
std::string corr = "";
|
std::string corr = "";
|
||||||
std::vector<std::string> parts;
|
std::vector<std::string> parts;
|
||||||
@ -442,38 +453,18 @@ private:
|
|||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string& newModeStr = parts[1];
|
||||||
float newBandwidth = std::atoi(parts[2].c_str());
|
float newBandwidth = std::atoi(parts[2].c_str());
|
||||||
|
|
||||||
int newMode;
|
auto it = std::find_if(radioModeToString.begin(), radioModeToString.end(), [&newModeStr](const auto& e) {
|
||||||
if (parts[1] == "FM") {
|
return e.second == newModeStr;
|
||||||
newMode = RADIO_IFACE_MODE_NFM;
|
});
|
||||||
}
|
if (it == radioModeToString.end()) {
|
||||||
else if (parts[1] == "WFM") {
|
|
||||||
newMode = RADIO_IFACE_MODE_WFM;
|
|
||||||
}
|
|
||||||
else if (parts[1] == "AM") {
|
|
||||||
newMode = RADIO_IFACE_MODE_AM;
|
|
||||||
}
|
|
||||||
else if (parts[1] == "DSB") {
|
|
||||||
newMode = RADIO_IFACE_MODE_DSB;
|
|
||||||
}
|
|
||||||
else if (parts[1] == "USB") {
|
|
||||||
newMode = RADIO_IFACE_MODE_USB;
|
|
||||||
}
|
|
||||||
else if (parts[1] == "CW") {
|
|
||||||
newMode = RADIO_IFACE_MODE_CW;
|
|
||||||
}
|
|
||||||
else if (parts[1] == "LSB") {
|
|
||||||
newMode = RADIO_IFACE_MODE_LSB;
|
|
||||||
}
|
|
||||||
else if (parts[1] == "RAW") {
|
|
||||||
newMode = RADIO_IFACE_MODE_RAW;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
resp = "RPRT 1\n";
|
resp = "RPRT 1\n";
|
||||||
client->write(resp.size(), (uint8_t*)resp.c_str());
|
client->write(resp.size(), (uint8_t*)resp.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
int newMode = it->first;
|
||||||
|
|
||||||
// If tuning is enabled, set the mode and optionally the bandwidth
|
// If tuning is enabled, set the mode and optionally the bandwidth
|
||||||
if (!selectedVfo.empty() && core::modComManager.getModuleName(selectedVfo) == "radio" && tuningEnabled) {
|
if (!selectedVfo.empty() && core::modComManager.getModuleName(selectedVfo) == "radio" && tuningEnabled) {
|
||||||
@ -492,31 +483,9 @@ private:
|
|||||||
if (!selectedVfo.empty() && core::modComManager.getModuleName(selectedVfo) == "radio") {
|
if (!selectedVfo.empty() && core::modComManager.getModuleName(selectedVfo) == "radio") {
|
||||||
int mode;
|
int mode;
|
||||||
core::modComManager.callInterface(selectedVfo, RADIO_IFACE_CMD_GET_MODE, NULL, &mode);
|
core::modComManager.callInterface(selectedVfo, RADIO_IFACE_CMD_GET_MODE, NULL, &mode);
|
||||||
|
resp = std::string(radioModeToString[mode]) + "\n";
|
||||||
if (mode == RADIO_IFACE_MODE_NFM) {
|
|
||||||
resp = "FM\n";
|
|
||||||
}
|
|
||||||
else if (mode == RADIO_IFACE_MODE_WFM) {
|
|
||||||
resp = "WFM\n";
|
|
||||||
}
|
|
||||||
else if (mode == RADIO_IFACE_MODE_AM) {
|
|
||||||
resp = "AM\n";
|
|
||||||
}
|
|
||||||
else if (mode == RADIO_IFACE_MODE_DSB) {
|
|
||||||
resp = "DSB\n";
|
|
||||||
}
|
|
||||||
else if (mode == RADIO_IFACE_MODE_USB) {
|
|
||||||
resp = "USB\n";
|
|
||||||
}
|
|
||||||
else if (mode == RADIO_IFACE_MODE_CW) {
|
|
||||||
resp = "CW\n";
|
|
||||||
}
|
|
||||||
else if (mode == RADIO_IFACE_MODE_LSB) {
|
|
||||||
resp = "LSB\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if (!selectedVfo.empty()) {
|
||||||
if (!selectedVfo.empty()) {
|
|
||||||
resp += std::to_string((int)sigpath::vfoManager.getBandwidth(selectedVfo)) + "\n";
|
resp += std::to_string((int)sigpath::vfoManager.getBandwidth(selectedVfo)) + "\n";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user