1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-23 08:28:36 -05:00

LimeSDR support (13)

This commit is contained in:
f4exb 2017-04-17 01:10:32 +02:00
parent 92e7bb8eba
commit 67a149ac06
4 changed files with 228 additions and 10 deletions

View File

@ -27,6 +27,9 @@
#include "limesdrinputthread.h"
#include "limesdr/devicelimesdrparam.h"
MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgConfigureLimeSDR, Message)
MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgReportLimeSDRToGUI, Message)
LimeSDRInput::LimeSDRInput(DeviceSourceAPI *deviceAPI) :
m_deviceAPI(deviceAPI),
@ -259,6 +262,13 @@ bool LimeSDRInput::handleMessage(const Message& message)
return true;
}
else if (MsgSetReferenceLimeSDR::match(message))
{
MsgSetReferenceLimeSDR& conf = (MsgSetReferenceLimeSDR&) message;
qDebug() << "LimeSDRInput::handleMessage: MsgSetReferenceLimeSDR";
m_settings = conf.getSettings();
return true;
}
else
{
return false;
@ -274,13 +284,13 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
qDebug() << "LimeSDRInput::applySettings";
if (m_settings.m_dcBlock != settings.m_dcBlock)
if ((m_settings.m_dcBlock != settings.m_dcBlock) || force)
{
m_settings.m_dcBlock = settings.m_dcBlock;
m_deviceAPI->configureCorrections(m_settings.m_dcBlock, m_settings.m_iqCorrection);
}
if (m_settings.m_iqCorrection != settings.m_iqCorrection)
if ((m_settings.m_iqCorrection != settings.m_iqCorrection) || force)
{
m_settings.m_iqCorrection = settings.m_iqCorrection;
m_deviceAPI->configureCorrections(m_settings.m_dcBlock, m_settings.m_iqCorrection);
@ -357,6 +367,33 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
}
}
if ((m_settings.m_lpfFIRBW != settings.m_lpfFIRBW) ||
(m_settings.m_lpfFIREnable != settings.m_lpfFIREnable) || force)
{
m_settings.m_lpfFIRBW = settings.m_lpfFIRBW;
m_settings.m_lpfFIREnable = settings.m_lpfFIREnable;
if (m_deviceShared.m_deviceParams->getDevice() != 0)
{
if (LMS_SetGFIRLPF(m_deviceShared.m_deviceParams->getDevice(),
LMS_CH_RX,
m_deviceShared.m_channel,
m_settings.m_lpfFIREnable,
m_settings.m_lpfFIRBW))
{
qCritical("LimeSDRInput::applySettings: could %s and set LPF FIR to %f Hz",
m_settings.m_lpfFIREnable ? "enable" : "disable",
m_settings.m_lpfFIRBW);
}
else
{
qDebug("LimeSDRInput::applySettings: %sd and set LPF FIR to %f Hz",
m_settings.m_lpfFIREnable ? "enable" : "disable",
m_settings.m_lpfFIRBW);
}
}
}
if ((m_settings.m_log2SoftDecim != settings.m_log2SoftDecim) || force)
{
m_settings.m_log2SoftDecim = settings.m_log2SoftDecim;
@ -369,7 +406,7 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
}
}
if (m_settings.m_centerFrequency != settings.m_centerFrequency)
if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || force)
{
forwardChangeRxDSP = true;
@ -387,11 +424,51 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
if (forwardChangeAllDSP)
{
const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
std::vector<DeviceSourceAPI*>::const_iterator itSource = sourceBuddies.begin();
int sampleRate = m_settings.m_devSampleRate/(1<<(m_settings.m_log2HardDecim + m_settings.m_log2SoftDecim));
for (; itSource != sourceBuddies.end(); ++itSource)
{
DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, m_settings.m_centerFrequency);
(*itSource)->getDeviceInputMessageQueue()->push(notif);
MsgReportLimeSDRToGUI *report = MsgReportLimeSDRToGUI::create(
m_settings.m_centerFrequency,
m_settings.m_devSampleRate,
m_settings.m_log2HardDecim);
(*itSource)->getDeviceInputMessageQueue()->push(report);
}
const std::vector<DeviceSinkAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
std::vector<DeviceSinkAPI*>::const_iterator itSink = sinkBuddies.begin();
for (; itSink != sinkBuddies.end(); ++itSink)
{
DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, m_settings.m_centerFrequency);
(*itSink)->getDeviceInputMessageQueue()->push(notif);
MsgReportLimeSDRToGUI *report = MsgReportLimeSDRToGUI::create(
m_settings.m_centerFrequency,
m_settings.m_devSampleRate,
m_settings.m_log2HardDecim);
(*itSink)->getDeviceInputMessageQueue()->push(report);
}
}
else if (forwardChangeRxDSP)
{
const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
std::vector<DeviceSourceAPI*>::const_iterator it = sourceBuddies.begin();
int sampleRate = m_settings.m_devSampleRate/(1<<(m_settings.m_log2HardDecim + m_settings.m_log2SoftDecim));
for (; it != sourceBuddies.end(); ++it)
{
DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, m_settings.m_centerFrequency);
(*it)->getDeviceInputMessageQueue()->push(notif);
MsgReportLimeSDRToGUI *report = MsgReportLimeSDRToGUI::create(
m_settings.m_centerFrequency,
m_settings.m_devSampleRate,
m_settings.m_log2HardDecim);
(*it)->getDeviceInputMessageQueue()->push(report);
}
}
else if (forwardChangeOwnDSP)
{

View File

@ -51,6 +51,52 @@ public:
{ }
};
class MsgSetReferenceLimeSDR : public Message {
MESSAGE_CLASS_DECLARATION
public:
const LimeSDRInputSettings& getSettings() const { return m_settings; }
static MsgSetReferenceLimeSDR* create(const LimeSDRInputSettings& settings)
{
return new MsgSetReferenceLimeSDR(settings);
}
private:
LimeSDRInputSettings m_settings;
MsgSetReferenceLimeSDR(const LimeSDRInputSettings& settings) :
Message(),
m_settings(settings)
{ }
};
class MsgReportLimeSDRToGUI : public Message {
MESSAGE_CLASS_DECLARATION
public:
float getCenterFrequency() const { return m_centerFrequency; }
int getSampleRate() const { return m_sampleRate; }
uint32_t getLog2HardDecim() const { return m_log2HardDecim; }
static MsgReportLimeSDRToGUI* create(float centerFrequency, int sampleRate, uint32_t log2HardDecim)
{
return new MsgReportLimeSDRToGUI(centerFrequency, sampleRate, log2HardDecim);
}
private:
float m_centerFrequency;
int m_sampleRate;
uint32_t m_log2HardDecim;
MsgReportLimeSDRToGUI(float centerFrequency, int sampleRate, uint32_t log2HardDecim) :
Message(),
m_centerFrequency(centerFrequency),
m_sampleRate(sampleRate),
m_log2HardDecim(log2HardDecim)
{ }
};
LimeSDRInput(DeviceSourceAPI *deviceAPI);
virtual ~LimeSDRInput();

View File

@ -34,7 +34,8 @@ LimeSDRInputGUI::LimeSDRInputGUI(DeviceSourceAPI *deviceAPI, QWidget* parent) :
m_settings(),
m_sampleSource(0),
m_sampleRate(0),
m_lastEngineState((DSPDeviceSourceEngine::State)-1)
m_lastEngineState((DSPDeviceSourceEngine::State)-1),
m_doApplySettings(true)
{
m_limeSDRInput = new LimeSDRInput(m_deviceAPI);
m_sampleSource = (DeviceSampleSource *) m_limeSDRInput;
@ -124,16 +125,24 @@ QByteArray LimeSDRInputGUI::serialize() const
bool LimeSDRInputGUI::deserialize(const QByteArray& data)
{
if(m_settings.deserialize(data)) {
if (m_settings.deserialize(data))
{
displaySettings();
sendSettings();
return true;
} else {
}
else
{
resetToDefaults();
return false;
}
}
bool LimeSDRInputGUI::handleMessage(const Message& message) // TODO: does not seem to be really useful in any of the source (+sink?) plugins
{
return false;
}
void LimeSDRInputGUI::handleMessagesToGUI()
{
Message* message;
@ -151,6 +160,23 @@ void LimeSDRInputGUI::handleMessagesToGUI()
updateSampleRateAndFrequency();
m_fileSink->handleMessage(*notif); // forward to file sink
delete message;
}
else if (LimeSDRInput::MsgReportLimeSDRToGUI::match(*message))
{
LimeSDRInput::MsgReportLimeSDRToGUI *report = (LimeSDRInput::MsgReportLimeSDRToGUI *) message;
m_settings.m_centerFrequency = report->getCenterFrequency() / 1000;
m_settings.m_devSampleRate = report->getSampleRate();
m_settings.m_log2HardDecim = report->getLog2HardDecim();
blockApplySettings(true);
displaySettings();
blockApplySettings(false);
LimeSDRInput::MsgSetReferenceLimeSDR* message = LimeSDRInput::MsgSetReferenceLimeSDR::create(m_settings);
m_sampleSource->getInputMessageQueue()->push(message);
delete message;
}
}
@ -192,10 +218,13 @@ void LimeSDRInputGUI::sendSettings()
void LimeSDRInputGUI::updateHardware()
{
if (m_doApplySettings)
{
qDebug() << "BladerfGui::updateHardware";
LimeSDRInput::MsgConfigureLimeSDR* message = LimeSDRInput::MsgConfigureLimeSDR::create(m_settings);
m_sampleSource->getInputMessageQueue()->push(message);
m_updateTimer.stop();
}
}
void LimeSDRInputGUI::updateStatus()
@ -227,3 +256,67 @@ void LimeSDRInputGUI::updateStatus()
}
}
void LimeSDRInputGUI::blockApplySettings(bool block)
{
m_doApplySettings = !block;
}
void LimeSDRInputGUI::on_startStop_toggled(bool checked)
{
}
void LimeSDRInputGUI::on_record_toggled(bool checked)
{
}
void LimeSDRInputGUI::on_centerFrequency_changed(quint64 value)
{
}
void LimeSDRInputGUI::on_dcOffset_toggled(bool checked)
{
}
void LimeSDRInputGUI::on_iqImbalance_toggled(bool checked)
{
}
void LimeSDRInputGUI::on_sampleRate_changed(quint64 value)
{
}
void LimeSDRInputGUI::on_hwDecim_currentIndexChanged(int index)
{
}
void LimeSDRInputGUI::on_swDecim_currentIndexChanged(int index)
{
}
void LimeSDRInputGUI::on_lpf_valueChanged(int value)
{
}
void LimeSDRInputGUI::on_lpFIREnable_toggled(bool checked)
{
}
void LimeSDRInputGUI::on_lpFIR_changed(quint64 value)
{
}
void LimeSDRInputGUI::on_gain_valueChanged(int value)
{
}

View File

@ -60,10 +60,12 @@ private:
int m_sampleRate;
quint64 m_deviceCenterFrequency; //!< Center frequency in device
int m_lastEngineState;
bool m_doApplySettings;
void displaySettings();
void sendSettings();
void updateSampleRateAndFrequency();
void blockApplySettings(bool block);
private slots:
void handleMessagesToGUI();