From c2b7092026d049a3e7762c8d7a928cf2aee760dc Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 19 Sep 2017 08:33:26 +0200 Subject: [PATCH] PlutoSDR output: interim state (2) --- devices/plutosdr/deviceplutosdrbox.cpp | 10 +++- devices/plutosdr/deviceplutosdrbox.h | 3 +- .../plutosdroutput/plutosdroutput.cpp | 52 ++++++++----------- .../plutosdrinput/plutosdrinput.cpp | 2 +- 4 files changed, 33 insertions(+), 34 deletions(-) diff --git a/devices/plutosdr/deviceplutosdrbox.cpp b/devices/plutosdr/deviceplutosdrbox.cpp index 4232132cc..32337218a 100644 --- a/devices/plutosdr/deviceplutosdrbox.cpp +++ b/devices/plutosdr/deviceplutosdrbox.cpp @@ -596,7 +596,7 @@ void DevicePlutoSDRBox::getXO() } } -bool DevicePlutoSDRBox::getRSSI(std::string& rssiStr, unsigned int chan) +bool DevicePlutoSDRBox::getRxRSSI(std::string& rssiStr, unsigned int chan) { chan = chan % 2; char buff[20]; @@ -604,6 +604,14 @@ bool DevicePlutoSDRBox::getRSSI(std::string& rssiStr, unsigned int chan) return get_param(DEVICE_PHY, buff, rssiStr); } +bool DevicePlutoSDRBox::getTxRSSI(std::string& rssiStr, unsigned int chan) +{ + chan = chan % 2; + char buff[20]; + snprintf(buff, sizeof(buff), "out_voltage%d_rssi", chan); + return get_param(DEVICE_PHY, buff, rssiStr); +} + bool DevicePlutoSDRBox::fetchTemp() { std::string temp_mC_str; diff --git a/devices/plutosdr/deviceplutosdrbox.h b/devices/plutosdr/deviceplutosdrbox.h index caeaab99a..8270f50f5 100644 --- a/devices/plutosdr/deviceplutosdrbox.h +++ b/devices/plutosdr/deviceplutosdrbox.h @@ -92,7 +92,8 @@ public: void setFIR(uint32_t sampleRate, uint32_t intdec, DeviceUse use, uint32_t bw, int gain); void setFIREnable(bool enable); void setLOPPMTenths(int ppmTenths); - bool getRSSI(std::string& rssiStr, unsigned int chan); + bool getRxRSSI(std::string& rssiStr, unsigned int chan); + bool getTxRSSI(std::string& rssiStr, unsigned int chan); bool fetchTemp(); float getTemp() const { return m_temp; } bool getRateGovernors(std::string& rateGovernors); diff --git a/plugins/samplesink/plutosdroutput/plutosdroutput.cpp b/plugins/samplesink/plutosdroutput/plutosdroutput.cpp index 9d5254522..ce09ee47a 100644 --- a/plugins/samplesink/plutosdroutput/plutosdroutput.cpp +++ b/plugins/samplesink/plutosdroutput/plutosdroutput.cpp @@ -321,46 +321,37 @@ bool PlutoSDROutput::applySettings(const PlutoSDROutputSettings& settings, bool if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force) { plutoBox->setLOPPMTenths(settings.m_LOppmTenths); - // TODO: forward change to Rx + forwardChangeOtherDSP = true; } - // TODO: continue from here - std::vector params; bool paramsToSet = false; if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || force) { - params.push_back(QString(tr("out_altvoltage0_RX_LO_frequency=%1").arg(settings.m_centerFrequency)).toStdString()); + params.push_back(QString(tr("out_altvoltage1_TX_LO_frequency=%1").arg(settings.m_centerFrequency)).toStdString()); paramsToSet = true; forwardChangeOwnDSP = true; } if ((m_settings.m_lpfBW != settings.m_lpfBW) || force) { - params.push_back(QString(tr("in_voltage_rf_bandwidth=%1").arg(settings.m_lpfBW)).toStdString()); + params.push_back(QString(tr("out_voltage_rf_bandwidth=%1").arg(settings.m_lpfBW)).toStdString()); paramsToSet = true; } if ((m_settings.m_antennaPath != settings.m_antennaPath) || force) { QString rfPortStr; - PlutoSDRInputSettings::translateRFPath(settings.m_antennaPath, rfPortStr); - params.push_back(QString(tr("in_voltage0_rf_port_select=%1").arg(rfPortStr)).toStdString()); + PlutoSDROutputSettings::translateRFPath(settings.m_antennaPath, rfPortStr); + params.push_back(QString(tr("out_voltage0_rf_port_select=%1").arg(rfPortStr)).toStdString()); paramsToSet = true; } - if ((m_settings.m_gainMode != settings.m_gainMode) || force) + if ((m_settings.m_att != settings.m_att) || force) { - QString gainModeStr; - PlutoSDRInputSettings::translateGainMode(settings.m_gainMode, gainModeStr); - params.push_back(QString(tr("in_voltage0_gain_control_mode=%1").arg(gainModeStr)).toStdString()); - paramsToSet = true; - } - - if ((m_settings.m_gain != settings.m_gain) || force) - { - params.push_back(QString(tr("in_voltage0_hardwaregain=%1").arg(settings.m_gain)).toStdString()); + float attF = settings.m_att * 0.25f; + params.push_back(QString(tr("out_voltage0_hardwaregain=%1").arg(attF)).toStdString()); paramsToSet = true; } @@ -373,12 +364,12 @@ bool PlutoSDROutput::applySettings(const PlutoSDROutputSettings& settings, bool if (suspendAllOtherThreads) { - const std::vector& sinkBuddies = m_deviceAPI->getSinkBuddies(); - std::vector::const_iterator itSink = sinkBuddies.begin(); + const std::vector& sourceBuddies = m_deviceAPI->getSourceBuddies(); + std::vector::const_iterator itSource = sourceBuddies.begin(); - for (; itSink != sinkBuddies.end(); ++itSink) + for (; itSource != sourceBuddies.end(); ++itSource) { - DevicePlutoSDRShared *buddySharedPtr = (DevicePlutoSDRShared *) (*itSink)->getBuddySharedPtr(); + DevicePlutoSDRShared *buddySharedPtr = (DevicePlutoSDRShared *) (*itSource)->getBuddySharedPtr(); if (buddySharedPtr->m_threadWasRunning) { buddySharedPtr->m_thread->startWork(); @@ -389,45 +380,44 @@ bool PlutoSDROutput::applySettings(const PlutoSDROutputSettings& settings, bool if (suspendOwnThread) { if (ownThreadWasRunning) { - m_plutoSDRInputThread->startWork(); + m_plutoSDROutputThread->startWork(); } } - // TODO: forward changes to other (Tx) DSP + // TODO: forward changes to other (Rx) DSP if (forwardChangeOtherDSP) { - qDebug("PlutoSDRInput::applySettings: forwardChangeOtherDSP"); + qDebug("PlutoSDROutput::applySettings: forwardChangeOtherDSP"); } if (forwardChangeOwnDSP) { - qDebug("PlutoSDRInput::applySettings: forward change to self"); + qDebug("PlutoSDROutput::applySettings: forward change to self"); - int sampleRate = m_settings.m_devSampleRate/(1<handleMessage(*notif); // forward to file sink m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif); } return true; } -void PlutoSDRInput::getRSSI(std::string& rssiStr) +void PlutoSDROutput::getRSSI(std::string& rssiStr) { DevicePlutoSDRBox *plutoBox = m_deviceShared.m_deviceParams->getBox(); - if (!plutoBox->getRSSI(rssiStr, 0)) { + if (!plutoBox->getTxRSSI(rssiStr, 0)) { rssiStr = "xxx dB"; } } -bool PlutoSDRInput::fetchTemperature() +bool PlutoSDROutput::fetchTemperature() { DevicePlutoSDRBox *plutoBox = m_deviceShared.m_deviceParams->getBox(); return plutoBox->fetchTemp(); } -float PlutoSDRInput::getTemperature() +float PlutoSDROutput::getTemperature() { DevicePlutoSDRBox *plutoBox = m_deviceShared.m_deviceParams->getBox(); return plutoBox->getTemp(); diff --git a/plugins/samplesource/plutosdrinput/plutosdrinput.cpp b/plugins/samplesource/plutosdrinput/plutosdrinput.cpp index 7302f252e..e9e043547 100644 --- a/plugins/samplesource/plutosdrinput/plutosdrinput.cpp +++ b/plugins/samplesource/plutosdrinput/plutosdrinput.cpp @@ -458,7 +458,7 @@ void PlutoSDRInput::getRSSI(std::string& rssiStr) { DevicePlutoSDRBox *plutoBox = m_deviceShared.m_deviceParams->getBox(); - if (!plutoBox->getRSSI(rssiStr, 0)) { + if (!plutoBox->getRxRSSI(rssiStr, 0)) { rssiStr = "xxx dB"; } }