more fixes

This commit is contained in:
Ryzerth 2021-07-20 03:03:22 +02:00
parent e877844768
commit 09e332a8d1
3 changed files with 25 additions and 23 deletions

View File

@ -120,22 +120,17 @@ private:
return; return;
} }
_this->digiGain = 0;
int srvBits = streamFormatsBitCount[_this->iqType]; 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_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_IQ_FREQUENCY, _this->freq);
_this->client->setSetting(SPYSERVER_SETTING_STREAMING_MODE, SPYSERVER_STREAM_MODE_IQ_ONLY); _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_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->client->startStream();
_this->running = true; _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) { static void stop(void* ctx) {
@ -253,14 +248,9 @@ private:
ImGui::SameLine(); ImGui::SameLine();
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX()); ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
if (ImGui::Combo("##spyserver_source_type", &_this->iqType, streamFormatStr)) { if (ImGui::Combo("##spyserver_source_type", &_this->iqType, streamFormatStr)) {
_this->digiGain = 0;
int srvBits = streamFormatsBitCount[_this->iqType]; 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_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.acquire();
config.conf["devices"][_this->devRef]["sampleBitDepthId"] = _this->iqType; config.conf["devices"][_this->devRef]["sampleBitDepthId"] = _this->iqType;
@ -270,20 +260,15 @@ private:
if (_this->client->devInfo.MaximumGainIndex) { if (_this->client->devInfo.MaximumGainIndex) {
ImGui::SetNextItemWidth(menuWidth); ImGui::SetNextItemWidth(menuWidth);
if (ImGui::SliderInt("##spyserver_source_gain", (int*)&_this->gain, 0, _this->client->devInfo.MaximumGainIndex)) { 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_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.acquire();
config.conf["devices"][_this->devRef]["gainId"] = _this->gain; config.conf["devices"][_this->devRef]["gainId"] = _this->gain;
config.release(true); 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::Text("Status:");
ImGui::SameLine(); ImGui::SameLine();
ImGui::TextColored(ImVec4(0.0f, 1.0f, 0.0f, 1.0f), "Connected (%s)", deviceTypesStr[_this->client->devInfo.DeviceType]); 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; std::string sampleRatesTxt;
uint32_t gain = 0; uint32_t gain = 0;
uint32_t digiGain = 0;
std::string devRef = ""; std::string devRef = "";

View File

@ -43,6 +43,22 @@ namespace spyserver {
return client->isOpen(); 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) { bool SpyServerClientClass::waitForDevInfo(int timeoutMS) {
std::unique_lock lck(deviceInfoMtx); std::unique_lock lck(deviceInfoMtx);
auto now = std::chrono::system_clock::now(); auto now = std::chrono::system_clock::now();
@ -102,7 +118,7 @@ namespace spyserver {
return; 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 mtype = _this->receivedHeader.MessageType & 0xFFFF;
int mflags = (_this->receivedHeader.MessageType & 0xFFFF0000) >> 16; int mflags = (_this->receivedHeader.MessageType & 0xFFFF0000) >> 16;

View File

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