mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2024-12-25 18:38:30 +01:00
SpyServer fixes
This commit is contained in:
parent
3103d2d168
commit
4b43da095e
@ -38,6 +38,12 @@ const SpyServerStreamFormat streamFormats[] = {
|
||||
SPYSERVER_STREAM_FORMAT_FLOAT
|
||||
};
|
||||
|
||||
const int streamFormatsBitCount[] = {
|
||||
8,
|
||||
16,
|
||||
32
|
||||
};
|
||||
|
||||
ConfigManager config;
|
||||
|
||||
class AirspyHFSourceModule : public ModuleManager::Instance {
|
||||
@ -113,18 +119,23 @@ private:
|
||||
if (_this->running) {
|
||||
return;
|
||||
}
|
||||
|
||||
int digiGain = 0;
|
||||
int srvBits = streamFormatsBitCount[_this->iqType];
|
||||
if (srvBits < _this->client->devInfo.Resolution) {
|
||||
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_FREQUENCY, _this->freq);
|
||||
_this->client->setSetting(SPYSERVER_SETTING_IQ_DIGITAL_GAIN, 0);
|
||||
_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, digiGain);
|
||||
_this->client->startStream();
|
||||
|
||||
_this->running = true;
|
||||
spdlog::info("AirspyHFSourceModule '{0}': Start!", _this->name);
|
||||
spdlog::info("AirspyHFSourceModule '{0}': Start with gain {1} !", _this->name, digiGain);
|
||||
}
|
||||
|
||||
static void stop(void* ctx) {
|
||||
@ -236,15 +247,25 @@ private:
|
||||
config.conf["devices"][_this->devRef]["sampleRateId"] = _this->srId;
|
||||
config.release(true);
|
||||
}
|
||||
if (_this->running) { style::endDisabled(); }
|
||||
|
||||
ImGui::Text("Sample bit depth");
|
||||
ImGui::SameLine();
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::Combo("##spyserver_source_type", &_this->iqType, streamFormatStr)) {
|
||||
int digiGain = 0;
|
||||
int srvBits = streamFormatsBitCount[_this->iqType];
|
||||
if (srvBits < _this->client->devInfo.Resolution) {
|
||||
digiGain = std::ceil(((double)_this->client->devInfo.Resolution - (double)srvBits)*6.02);
|
||||
spdlog::info("Switched the digital gain to {0}dB", digiGain);
|
||||
}
|
||||
_this->client->setSetting(SPYSERVER_SETTING_IQ_FORMAT, streamFormats[_this->iqType]);
|
||||
_this->client->setSetting(SPYSERVER_SETTING_IQ_DIGITAL_GAIN, digiGain);
|
||||
|
||||
config.acquire();
|
||||
config.conf["devices"][_this->devRef]["sampleBitDepthId"] = _this->iqType;
|
||||
config.release(true);
|
||||
}
|
||||
if (_this->running) { style::endDisabled(); }
|
||||
|
||||
if (_this->client->devInfo.MaximumGainIndex) {
|
||||
ImGui::SetNextItemWidth(menuWidth);
|
||||
|
@ -92,15 +92,22 @@ namespace spyserver {
|
||||
void SpyServerClientClass::dataHandler(int count, uint8_t* buf, void* ctx) {
|
||||
SpyServerClientClass* _this = (SpyServerClientClass*)ctx;
|
||||
|
||||
int size = _this->readSize(_this->receivedHeader.BodySize, _this->readBuf);
|
||||
if (size <= 0) {
|
||||
printf("ERROR: Didn't receive enough bytes\n");
|
||||
if (count < sizeof(SpyServerMessageHeader)) {
|
||||
printf("ERROR: Incomplete message header\n");
|
||||
return;
|
||||
}
|
||||
|
||||
//printf("MSG %08X %d %d %08X %d\n", _this->receivedHeader.ProtocolID, _this->receivedHeader.MessageType, _this->receivedHeader.StreamType, _this->receivedHeader.SequenceNumber, _this->receivedHeader.BodySize);
|
||||
int size = _this->readSize(_this->receivedHeader.BodySize, _this->readBuf);
|
||||
if (size <= 0) {
|
||||
printf("ERROR: Disconnected\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_this->receivedHeader.MessageType == SPYSERVER_MSG_TYPE_DEVICE_INFO) {
|
||||
//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;
|
||||
|
||||
if (mtype == SPYSERVER_MSG_TYPE_DEVICE_INFO) {
|
||||
{
|
||||
std::lock_guard lck(_this->deviceInfoMtx);
|
||||
SpyServerDeviceInfo* _devInfo = (SpyServerDeviceInfo*)_this->readBuf;
|
||||
@ -109,7 +116,7 @@ namespace spyserver {
|
||||
}
|
||||
_this->deviceInfoCnd.notify_all();
|
||||
}
|
||||
else if (_this->receivedHeader.MessageType == SPYSERVER_MSG_TYPE_UINT8_IQ) {
|
||||
else if (mtype == SPYSERVER_MSG_TYPE_UINT8_IQ) {
|
||||
int sampCount = _this->receivedHeader.BodySize / (sizeof(uint8_t)*2);
|
||||
for (int i = 0; i < sampCount; i++) {
|
||||
_this->output->writeBuf[i].re = ((float)_this->readBuf[(2*i)] / 128.0f)-1.0f;
|
||||
@ -117,16 +124,16 @@ namespace spyserver {
|
||||
}
|
||||
_this->output->swap(sampCount);
|
||||
}
|
||||
else if (_this->receivedHeader.MessageType == SPYSERVER_MSG_TYPE_INT16_IQ) {
|
||||
else if (mtype == SPYSERVER_MSG_TYPE_INT16_IQ) {
|
||||
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);
|
||||
_this->output->swap(sampCount);
|
||||
}
|
||||
else if (_this->receivedHeader.MessageType == SPYSERVER_MSG_TYPE_INT24_IQ) {
|
||||
else if (mtype == SPYSERVER_MSG_TYPE_INT24_IQ) {
|
||||
printf("ERROR: IQ format not supported\n");
|
||||
return;
|
||||
}
|
||||
else if (_this->receivedHeader.MessageType == SPYSERVER_MSG_TYPE_FLOAT_IQ) {
|
||||
else if (mtype == SPYSERVER_MSG_TYPE_FLOAT_IQ) {
|
||||
int sampCount = _this->receivedHeader.BodySize / sizeof(dsp::complex_t);
|
||||
memcpy(_this->output->writeBuf, _this->readBuf, _this->receivedHeader.BodySize);
|
||||
_this->output->swap(sampCount);
|
||||
|
Loading…
Reference in New Issue
Block a user