mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-01-23 16:34:43 +01:00
More fixes idk
This commit is contained in:
parent
0bc1bd8549
commit
4634c8187f
@ -33,7 +33,7 @@ else (MSVC)
|
||||
|
||||
# Include it because for some reason pkgconfig doesn't look here?
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
target_include_directories(airspy_source PUBLIC "/usr/local/include")
|
||||
target_include_directories(airspyhf_source PUBLIC "/usr/local/include")
|
||||
endif()
|
||||
|
||||
endif ()
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
BladeRFSourceModule(std::string name) {
|
||||
this->name = name;
|
||||
|
||||
sampleRate = 768000.0;
|
||||
sampleRate = 1000000.0;
|
||||
|
||||
handler.ctx = this;
|
||||
handler.selectHandler = menuSelected;
|
||||
@ -119,7 +119,8 @@ public:
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < devCount; i++) {
|
||||
devListTxt += devInfoList[i].serial;
|
||||
// Keep only the first 32 character of the serial number for display
|
||||
devListTxt += std::string(devInfoList[i].serial).substr(0, 32);
|
||||
devListTxt += '\0';
|
||||
}
|
||||
}
|
||||
@ -135,15 +136,14 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
// Gather info about the BladeRF
|
||||
// Gather info about the BladeRF's ranges
|
||||
channelCount = bladerf_get_channel_count(openDev, BLADERF_RX);
|
||||
bladerf_get_sample_rate_range(openDev, BLADERF_CHANNEL_RX(0), &srRange);
|
||||
bladerf_get_bandwidth_range(openDev, BLADERF_CHANNEL_RX(0), &bwRange);
|
||||
bladerf_get_gain_range(openDev, BLADERF_CHANNEL_RX(0), &gainRange);
|
||||
|
||||
spdlog::warn("SR Range: {0}, {1}, {2}, {3}", srRange->min, srRange->max, srRange->step, srRange->scale);
|
||||
spdlog::warn("BW Range: {0}, {1}, {2}, {3}", bwRange->min, bwRange->max, bwRange->step, bwRange->scale);
|
||||
spdlog::warn("Gain Range: {0}, {1}, {2}, {3}", gainRange->min, gainRange->max, gainRange->step, gainRange->scale);
|
||||
srId = 1;
|
||||
sampleRate = sampleRates[1];
|
||||
|
||||
// TODO: Gen sample rate list automatically by detecting which version is selected
|
||||
|
||||
@ -191,28 +191,23 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate buffer size, must be a multiple of 1024
|
||||
_this->bufferSize = _this->sampleRate / 200.0;
|
||||
_this->bufferSize /= 1024;
|
||||
_this->bufferSize *= 1024;
|
||||
if (_this->bufferSize < 1024) { _this->bufferSize = 1024; }
|
||||
|
||||
bladerf_sample_rate wantedSr = _this->sampleRate;
|
||||
bladerf_sample_rate actualSr;
|
||||
bladerf_sample_rate actualBw;
|
||||
bladerf_set_sample_rate(_this->openDev, BLADERF_CHANNEL_RX(0), wantedSr, &actualSr);
|
||||
// Setup device parameters
|
||||
bladerf_set_sample_rate(_this->openDev, BLADERF_CHANNEL_RX(0), _this->sampleRate, NULL);
|
||||
bladerf_set_frequency(_this->openDev, BLADERF_CHANNEL_RX(0), _this->freq);
|
||||
bladerf_set_bandwidth(_this->openDev, BLADERF_CHANNEL_RX(0), 56000000, &actualBw);
|
||||
bladerf_set_bandwidth(_this->openDev, BLADERF_CHANNEL_RX(0), 56000000, NULL);
|
||||
bladerf_set_gain_mode(_this->openDev, BLADERF_CHANNEL_RX(0), BLADERF_GAIN_MANUAL);
|
||||
bladerf_set_gain(_this->openDev, BLADERF_CHANNEL_RX(0), _this->testGain);
|
||||
|
||||
if (actualSr != wantedSr) {
|
||||
spdlog::warn("Sample rate rejected: {0} vs {1}", actualSr, wantedSr);
|
||||
return;
|
||||
}
|
||||
|
||||
// Setup syncronous transfer
|
||||
bladerf_sync_config(_this->openDev, BLADERF_RX_X1, BLADERF_FORMAT_SC16_Q11, 16, _this->bufferSize, 8, 3500);
|
||||
|
||||
// Enable streaming
|
||||
bladerf_enable_module(_this->openDev, BLADERF_CHANNEL_RX(0), true);
|
||||
|
||||
_this->running = true;
|
||||
@ -229,11 +224,15 @@ private:
|
||||
_this->running = false;
|
||||
_this->stream.stopWriter();
|
||||
|
||||
// Disable streaming
|
||||
bladerf_enable_module(_this->openDev, BLADERF_CHANNEL_RX(0), false);
|
||||
|
||||
// Wait for read worker to terminate
|
||||
if (_this->workerThread.joinable()) {
|
||||
_this->workerThread.join();
|
||||
}
|
||||
|
||||
// Close device
|
||||
bladerf_close(_this->openDev);
|
||||
|
||||
_this->stream.clearWriteStop();
|
||||
@ -294,12 +293,17 @@ private:
|
||||
void worker() {
|
||||
int16_t* buffer = new int16_t[bufferSize * 2];
|
||||
bladerf_metadata meta;
|
||||
|
||||
while (true) {
|
||||
// Receive from the stream and break on error
|
||||
int ret = bladerf_sync_rx(openDev, buffer, bufferSize, &meta, 3500);
|
||||
if (ret != 0) { printf("Error: %d\n", ret); break; }
|
||||
if (ret != 0) { break; }
|
||||
|
||||
// Convert to complex float and swap buffers
|
||||
volk_16i_s32f_convert_32f((float*)stream.writeBuf, buffer, 32768.0f, bufferSize * 2);
|
||||
if (!stream.swap(bufferSize)) { break; }
|
||||
}
|
||||
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
|
@ -128,10 +128,7 @@ private:
|
||||
|
||||
while (true) {
|
||||
_this->reader->readSamples(inBuf, blockSize * 2 * sizeof(int16_t));
|
||||
for (int i = 0; i < blockSize; i++) {
|
||||
_this->stream.writeBuf[i].re = (float)inBuf[i * 2] / (float)0x7FFF;
|
||||
_this->stream.writeBuf[i].im = (float)inBuf[(i * 2) + 1] / (float)0x7FFF;
|
||||
}
|
||||
volk_16i_s32f_convert_32f((float*)_this->stream.writeBuf, inBuf, 32768.0f, blockSize * 2);
|
||||
if (!_this->stream.swap(blockSize)) { break; };
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user