More spyserver bugfix

This commit is contained in:
Ryzerth 2021-07-19 22:23:03 +02:00
parent c9f1ec0a8a
commit e877844768
2 changed files with 29 additions and 16 deletions

View File

@ -120,10 +120,10 @@ private:
return; return;
} }
int digiGain = 0; _this->digiGain = 0;
int srvBits = streamFormatsBitCount[_this->iqType]; int srvBits = streamFormatsBitCount[_this->iqType];
if (srvBits < _this->client->devInfo.Resolution) { if (srvBits < _this->client->devInfo.Resolution) {
digiGain = std::ceil(((double)_this->client->devInfo.Resolution - (double)srvBits)*6.02); _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]);
@ -131,11 +131,11 @@ private:
_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, digiGain); _this->client->setSetting(SPYSERVER_SETTING_IQ_DIGITAL_GAIN, _this->digiGain);
_this->client->startStream(); _this->client->startStream();
_this->running = true; _this->running = true;
spdlog::info("AirspyHFSourceModule '{0}': Start with gain {1} !", _this->name, digiGain); spdlog::info("AirspyHFSourceModule '{0}': Start with gain {1} !", _this->name, _this->digiGain);
} }
static void stop(void* ctx) { static void stop(void* ctx) {
@ -253,14 +253,14 @@ 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)) {
int digiGain = 0; _this->digiGain = 0;
int srvBits = streamFormatsBitCount[_this->iqType]; int srvBits = streamFormatsBitCount[_this->iqType];
if (srvBits < _this->client->devInfo.Resolution) { if (srvBits < _this->client->devInfo.Resolution) {
digiGain = std::ceil(((double)_this->client->devInfo.Resolution - (double)srvBits)*6.02); _this->digiGain = std::ceil(((double)_this->client->devInfo.Resolution - (double)srvBits)*6.02);
spdlog::info("Switched the digital gain to {0}dB", digiGain); 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, digiGain); _this->client->setSetting(SPYSERVER_SETTING_IQ_DIGITAL_GAIN, _this->digiGain);
config.acquire(); config.acquire();
config.conf["devices"][_this->devRef]["sampleBitDepthId"] = _this->iqType; config.conf["devices"][_this->devRef]["sampleBitDepthId"] = _this->iqType;
@ -269,7 +269,7 @@ private:
if (_this->client->devInfo.MaximumGainIndex) { if (_this->client->devInfo.MaximumGainIndex) {
ImGui::SetNextItemWidth(menuWidth); ImGui::SetNextItemWidth(menuWidth);
if (ImGui::SliderInt("##spyserver_source_gain", &_this->gain, 0, _this->client->devInfo.MaximumGainIndex)) { if (ImGui::SliderInt("##spyserver_source_gain", (int*)&_this->gain, 0, _this->client->devInfo.MaximumGainIndex)) {
_this->client->setSetting(SPYSERVER_SETTING_GAIN, _this->gain); _this->client->setSetting(SPYSERVER_SETTING_GAIN, _this->gain);
config.acquire(); config.acquire();
config.conf["devices"][_this->devRef]["gainId"] = _this->gain; config.conf["devices"][_this->devRef]["gainId"] = _this->gain;
@ -277,6 +277,13 @@ private:
} }
} }
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]);
@ -302,7 +309,8 @@ private:
std::vector<double> sampleRates; std::vector<double> sampleRates;
std::string sampleRatesTxt; std::string sampleRatesTxt;
int gain = 0; uint32_t gain = 0;
uint32_t digiGain = 0;
std::string devRef = ""; std::string devRef = "";

View File

@ -102,9 +102,10 @@ 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;
if (mtype == SPYSERVER_MSG_TYPE_DEVICE_INFO) { if (mtype == SPYSERVER_MSG_TYPE_DEVICE_INFO) {
{ {
@ -117,15 +118,18 @@ namespace spyserver {
} }
else if (mtype == SPYSERVER_MSG_TYPE_UINT8_IQ) { else if (mtype == SPYSERVER_MSG_TYPE_UINT8_IQ) {
int sampCount = _this->receivedHeader.BodySize / (sizeof(uint8_t)*2); int sampCount = _this->receivedHeader.BodySize / (sizeof(uint8_t)*2);
float gain = pow(10, (double)mflags / 20.0);
float scale = 1.0f / (gain * 128.0f);
for (int i = 0; i < sampCount; i++) { for (int i = 0; i < sampCount; i++) {
_this->output->writeBuf[i].re = ((float)_this->readBuf[(2*i)] / 128.0f)-1.0f; _this->output->writeBuf[i].re = ((float)_this->readBuf[(2*i)] - 128.0f) * scale;
_this->output->writeBuf[i].im = ((float)_this->readBuf[(2*i)+1] / 128.0f)-1.0f; _this->output->writeBuf[i].im = ((float)_this->readBuf[(2*i)+1] - 128.0f) * scale;
} }
_this->output->swap(sampCount); _this->output->swap(sampCount);
} }
else if (mtype == SPYSERVER_MSG_TYPE_INT16_IQ) { else if (mtype == SPYSERVER_MSG_TYPE_INT16_IQ) {
int sampCount = _this->receivedHeader.BodySize / (sizeof(int16_t)*2); int sampCount = _this->receivedHeader.BodySize / (sizeof(int16_t)*2);
volk_16i_s32f_convert_32f((float*)_this->output->writeBuf, (int16_t*)_this->readBuf, 32768.0, sampCount*2); float gain = pow(10, (double)mflags / 20.0);
volk_16i_s32f_convert_32f((float*)_this->output->writeBuf, (int16_t*)_this->readBuf, 32768.0 * gain, sampCount*2);
_this->output->swap(sampCount); _this->output->swap(sampCount);
} }
else if (mtype == SPYSERVER_MSG_TYPE_INT24_IQ) { else if (mtype == SPYSERVER_MSG_TYPE_INT24_IQ) {
@ -134,7 +138,8 @@ namespace spyserver {
} }
else if (mtype == SPYSERVER_MSG_TYPE_FLOAT_IQ) { else if (mtype == SPYSERVER_MSG_TYPE_FLOAT_IQ) {
int sampCount = _this->receivedHeader.BodySize / sizeof(dsp::complex_t); int sampCount = _this->receivedHeader.BodySize / sizeof(dsp::complex_t);
memcpy(_this->output->writeBuf, _this->readBuf, _this->receivedHeader.BodySize); float gain = pow(10, (double)mflags / 20.0);
volk_32f_s32f_multiply_32f((float*)_this->output->writeBuf, (float*)_this->readBuf, gain, sampCount*2);
_this->output->swap(sampCount); _this->output->swap(sampCount);
} }