Fixed RTL-TCP bug

pull/276/head
Ryzerth 2021-07-21 16:23:03 +02:00
rodzic a974658c98
commit 2baf607b8c
2 zmienionych plików z 35 dodań i 10 usunięć

Wyświetl plik

@ -70,6 +70,7 @@ public:
tunerAGC = config.conf["tunerAGC"];
gain = config.conf["gainIndex"];
biasTee = config.conf["biasTee"];
offsetTuning = config.conf["offsetTuning"];
hostStr = hostStr.substr(0, 1023);
strcpy(ip, hostStr.c_str());
config.release();
@ -130,6 +131,7 @@ private:
_this->client.setAGCMode(_this->rtlAGC);
_this->client.setGainIndex(_this->gain);
_this->client.setBiasTee(_this->biasTee);
_this->client.setOffsetTuning(_this->offsetTuning);
_this->running = true;
_this->workerThread = std::thread(worker, _this);
spdlog::info("RTLTCPSourceModule '{0}': Start!", _this->name);
@ -186,14 +188,28 @@ private:
if (_this->running) { style::endDisabled(); }
ImGui::SetNextItemWidth(ImGui::CalcTextSize("OOOOOOOOOO").x);
if (ImGui::Combo(CONCAT("Direct Sampling##_rtltcp_ds_", _this->name), &_this->directSamplingMode, "Disabled\0I branch\0Q branch\0")) {
ImGui::Text("Direct Sampling");
ImGui::SameLine();
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
if (ImGui::Combo(CONCAT("##_rtltcp_ds_", _this->name), &_this->directSamplingMode, "Disabled\0I branch\0Q branch\0")) {
if (_this->running) {
_this->client.setDirectSampling(_this->directSamplingMode);
_this->client.setGainIndex(_this->gain);
}
}
if (ImGui::Checkbox(CONCAT("Bias-T##_biast_select_", _this->name), &_this->biasTee)) {
if (_this->running) {
_this->client.setBiasTee(_this->biasTee);
}
}
if (ImGui::Checkbox(CONCAT("Offset Tuning##_biast_select_", _this->name), &_this->offsetTuning)) {
if (_this->running) {
_this->client.setOffsetTuning(_this->offsetTuning);
}
}
if (ImGui::Checkbox("RTL AGC", &_this->rtlAGC)) {
if (_this->running) {
_this->client.setAGCMode(_this->rtlAGC);
@ -220,12 +236,6 @@ private:
}
}
if (_this->tunerAGC) { style::endDisabled(); }
if (ImGui::Checkbox(CONCAT("Bias-T##_biast_select_", _this->name), &_this->biasTee)) {
if (_this->running) {
_this->client.setBiasTee(_this->biasTee);
}
}
}
static void worker(void* ctx) {
@ -263,6 +273,7 @@ private:
int directSamplingMode = 0;
int srId = 0;
bool biasTee = false;
bool offsetTuning = false;
std::string srTxt = "";
};
@ -277,6 +288,7 @@ MOD_EXPORT void _INIT_() {
defConf["tunerAGC"] = false;
defConf["gainIndex"] = 0;
defConf["biasTee"] = false;
defConf["offsetTuning"] = false;
config.load(defConf);
config.enableAutoSave();
@ -284,6 +296,9 @@ MOD_EXPORT void _INIT_() {
if (!config.conf.contains("biasTee")) {
config.conf["biasTee"] = false;
}
if (!config.conf.contains("offsetTuning")) {
config.conf["offsetTuning"] = false;
}
config.release(true);
}

Wyświetl plik

@ -137,11 +137,17 @@ public:
}
void receiveData(uint8_t* buf, size_t count) {
int received = 0;
int ret = 0;
while (received < count) {
#ifdef _WIN32
recv(sock, (char*)buf, count, 0);
ret = recv(sock, (char*)&buf[received], count - received, 0);
#else
(void)read(sockfd, buf, count);
ret = read(sockfd, &buf[received], count - received);
#endif
if (ret <= 0) { return; }
received += ret;
}
}
void setFrequency(double freq) {
@ -168,6 +174,10 @@ public:
sendCommand(9, mode);
}
void setOffsetTuning(bool enabled) {
sendCommand(10, enabled);
}
void setGainIndex(int index) {
sendCommand(13, index);
}