pull/180/head
Ryzerth 2021-07-20 03:03:22 +02:00
rodzic e877844768
commit 09e332a8d1
3 zmienionych plików z 25 dodań i 23 usunięć

Wyświetl plik

@ -120,22 +120,17 @@ private:
return;
}
_this->digiGain = 0;
int srvBits = streamFormatsBitCount[_this->iqType];
if (srvBits < _this->client->devInfo.Resolution) {
_this->digiGain = std::ceil(((double)_this->client->devInfo.Resolution - (double)srvBits)*6.02);
}
_this->client->setSetting(SPYSERVER_SETTING_IQ_FORMAT, streamFormats[_this->iqType]);
_this->client->setSetting(SPYSERVER_SETTING_IQ_DECIMATION, _this->srId);
_this->client->setSetting(SPYSERVER_SETTING_IQ_DECIMATION, _this->srId + _this->client->devInfo.MinimumIQDecimation);
_this->client->setSetting(SPYSERVER_SETTING_IQ_FREQUENCY, _this->freq);
_this->client->setSetting(SPYSERVER_SETTING_STREAMING_MODE, SPYSERVER_STREAM_MODE_IQ_ONLY);
_this->client->setSetting(SPYSERVER_SETTING_GAIN, _this->gain);
_this->client->setSetting(SPYSERVER_SETTING_IQ_DIGITAL_GAIN, _this->digiGain);
_this->client->setSetting(SPYSERVER_SETTING_IQ_DIGITAL_GAIN, _this->client->computeDigitalGain(srvBits, _this->gain, _this->srId + _this->client->devInfo.MinimumIQDecimation));
_this->client->startStream();
_this->running = true;
spdlog::info("AirspyHFSourceModule '{0}': Start with gain {1} !", _this->name, _this->digiGain);
spdlog::info("AirspyHFSourceModule '{0}': Start!", _this->name);
}
static void stop(void* ctx) {
@ -253,14 +248,9 @@ private:
ImGui::SameLine();
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
if (ImGui::Combo("##spyserver_source_type", &_this->iqType, streamFormatStr)) {
_this->digiGain = 0;
int srvBits = streamFormatsBitCount[_this->iqType];
if (srvBits < _this->client->devInfo.Resolution) {
_this->digiGain = std::ceil(((double)_this->client->devInfo.Resolution - (double)srvBits)*6.02);
spdlog::info("Switched the digital gain to {0}dB", _this->digiGain);
}
_this->client->setSetting(SPYSERVER_SETTING_IQ_FORMAT, streamFormats[_this->iqType]);
_this->client->setSetting(SPYSERVER_SETTING_IQ_DIGITAL_GAIN, _this->digiGain);
_this->client->setSetting(SPYSERVER_SETTING_IQ_DIGITAL_GAIN, _this->client->computeDigitalGain(srvBits, _this->gain, _this->srId + _this->client->devInfo.MinimumIQDecimation));
config.acquire();
config.conf["devices"][_this->devRef]["sampleBitDepthId"] = _this->iqType;
@ -270,20 +260,15 @@ private:
if (_this->client->devInfo.MaximumGainIndex) {
ImGui::SetNextItemWidth(menuWidth);
if (ImGui::SliderInt("##spyserver_source_gain", (int*)&_this->gain, 0, _this->client->devInfo.MaximumGainIndex)) {
int srvBits = streamFormatsBitCount[_this->iqType];
_this->client->setSetting(SPYSERVER_SETTING_GAIN, _this->gain);
_this->client->setSetting(SPYSERVER_SETTING_IQ_DIGITAL_GAIN, _this->client->computeDigitalGain(srvBits, _this->gain, _this->srId + _this->client->devInfo.MinimumIQDecimation));
config.acquire();
config.conf["devices"][_this->devRef]["gainId"] = _this->gain;
config.release(true);
}
}
ImGui::Text("Digital Gain");
ImGui::SameLine();
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
if (ImGui::InputInt("##spyserver_source_dgain", (int*)&_this->digiGain, 1, 10)) {
_this->client->setSetting(SPYSERVER_SETTING_IQ_DIGITAL_GAIN, _this->digiGain);
}
ImGui::Text("Status:");
ImGui::SameLine();
ImGui::TextColored(ImVec4(0.0f, 1.0f, 0.0f, 1.0f), "Connected (%s)", deviceTypesStr[_this->client->devInfo.DeviceType]);
@ -310,7 +295,6 @@ private:
std::string sampleRatesTxt;
uint32_t gain = 0;
uint32_t digiGain = 0;
std::string devRef = "";

Wyświetl plik

@ -43,6 +43,22 @@ namespace spyserver {
return client->isOpen();
}
int SpyServerClientClass::computeDigitalGain(int serverBits, int deviceGain, int decimationId) {
if (devInfo.DeviceType == SPYSERVER_DEVICE_AIRSPY_ONE) {
return (devInfo.MaximumGainIndex - deviceGain) + (decimationId * 3.01f);
}
else if (devInfo.DeviceType == SPYSERVER_DEVICE_AIRSPY_HF) {
return decimationId * 3.01f;
}
else if (devInfo.DeviceType == SPYSERVER_DEVICE_RTLSDR) {
return decimationId * 3.01f;
}
else {
// Error, unknown device
return -1;
}
}
bool SpyServerClientClass::waitForDevInfo(int timeoutMS) {
std::unique_lock lck(deviceInfoMtx);
auto now = std::chrono::system_clock::now();
@ -102,7 +118,7 @@ namespace spyserver {
return;
}
printf("MSG Proto: 0x%08X, MsgType: 0x%08X, StreamType: 0x%08X, Seq: 0x%08X, Size: %d\n", _this->receivedHeader.ProtocolID, _this->receivedHeader.MessageType, _this->receivedHeader.StreamType, _this->receivedHeader.SequenceNumber, _this->receivedHeader.BodySize);
//printf("MSG Proto: 0x%08X, MsgType: 0x%08X, StreamType: 0x%08X, Seq: 0x%08X, Size: %d\n", _this->receivedHeader.ProtocolID, _this->receivedHeader.MessageType, _this->receivedHeader.StreamType, _this->receivedHeader.SequenceNumber, _this->receivedHeader.BodySize);
int mtype = _this->receivedHeader.MessageType & 0xFFFF;
int mflags = (_this->receivedHeader.MessageType & 0xFFFF0000) >> 16;

Wyświetl plik

@ -20,6 +20,8 @@ namespace spyserver {
void close();
bool isOpen();
int computeDigitalGain(int serverBits, int deviceGain, int decimationId);
SpyServerDeviceInfo devInfo;
private: