Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lime: Implement #1389 #1395

Merged
merged 1 commit into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions plugins/samplesink/limesdroutput/limesdroutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

MESSAGE_CLASS_DEFINITION(LimeSDROutput::MsgConfigureLimeSDR, Message)
MESSAGE_CLASS_DEFINITION(LimeSDROutput::MsgStartStop, Message)
MESSAGE_CLASS_DEFINITION(LimeSDROutput::MsgCalibrationResult, Message)
MESSAGE_CLASS_DEFINITION(LimeSDROutput::MsgGetStreamInfo, Message)
MESSAGE_CLASS_DEFINITION(LimeSDROutput::MsgGetDeviceInfo, Message)
MESSAGE_CLASS_DEFINITION(LimeSDROutput::MsgReportStreamInfo, Message)
Expand Down Expand Up @@ -1066,19 +1067,20 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo

if (doCalibration)
{
double bw = std::min((double)m_settings.m_devSampleRate, 2500000.0); // Min supported calibration bandwidth is 2.5MHz
if (LMS_Calibrate(m_deviceShared.m_deviceParams->getDevice(),
LMS_CH_TX,
m_deviceShared.m_channel,
bw,
0) != 0)
{
double bw = std::max((double)m_settings.m_devSampleRate, 2500000.0); // Min supported calibration bandwidth is 2.5MHz
bool calibrationOK = LMS_Calibrate(m_deviceShared.m_deviceParams->getDevice(),
LMS_CH_TX,
m_deviceShared.m_channel,
bw,
0) == 0;
if (!calibrationOK) {
qCritical("LimeSDROutput::applySettings: calibration failed on Tx channel %d", m_deviceShared.m_channel);
}
else
{
} else {
qDebug("LimeSDROutput::applySettings: calibration successful on Tx channel %d", m_deviceShared.m_channel);
}
if (m_guiMessageQueue) {
m_guiMessageQueue->push(MsgCalibrationResult::create(calibrationOK));
}
}

if (doLPCalibration)
Expand Down
19 changes: 19 additions & 0 deletions plugins/samplesink/limesdroutput/limesdroutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,25 @@ class LimeSDROutput : public DeviceSampleSink
{ }
};

class MsgCalibrationResult : public Message {
MESSAGE_CLASS_DECLARATION

public:
bool getSuccess() const { return m_success; }

static MsgCalibrationResult* create(bool success) {
return new MsgCalibrationResult(success);
}

protected:
bool m_success;

MsgCalibrationResult(bool success) :
Message(),
m_success(success)
{ }
};

class MsgGetStreamInfo : public Message {
MESSAGE_CLASS_DECLARATION

Expand Down
37 changes: 37 additions & 0 deletions plugins/samplesink/limesdroutput/limesdroutputgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,16 @@ bool LimeSDROutputGUI::handleMessage(const Message& message)

return true;
}
else if (LimeSDROutput::MsgCalibrationResult::match(message))
{
LimeSDROutput::MsgCalibrationResult& report = (LimeSDROutput::MsgCalibrationResult&) message;

if (report.getSuccess()) {
ui->calibrationLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }");
} else {
ui->calibrationLabel->setStyleSheet("QLabel { background-color : red; }");
}
}
else if (LimeSDROutput::MsgReportStreamInfo::match(message))
{
LimeSDROutput::MsgReportStreamInfo& report = (LimeSDROutput::MsgReportStreamInfo&) message;
Expand Down Expand Up @@ -303,6 +313,32 @@ void LimeSDROutputGUI::updateSampleRateAndFrequency()
m_deviceUISet->getSpectrum()->setSampleRate(m_sampleRate);
m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency);
displaySampleRate();
checkLPF();
}

// Check if LPF BW is set wide enough when down-converting using NCO
void LimeSDROutputGUI::checkLPF()
{
bool highlightLPFLabel = false;
int64_t centerFrequency = m_settings.m_centerFrequency;
if (m_settings.m_ncoEnable) {
centerFrequency += m_settings.m_ncoFrequency;
}
if (centerFrequency < 30000000)
{
int64_t requiredBW = 30000000 - centerFrequency;
highlightLPFLabel = m_settings.m_lpfBW < requiredBW;
}
if (highlightLPFLabel)
{
ui->lpfLabel->setStyleSheet("QLabel { background-color : red; }");
ui->lpfLabel->setToolTip("LPF BW is too low for selected center frequency");
}
else
{
ui->lpfLabel->setStyleSheet("QLabel { background-color: rgb(64, 64, 64); }");
ui->lpfLabel->setToolTip("");
}
}

void LimeSDROutputGUI::updateDACRate()
Expand Down Expand Up @@ -573,6 +609,7 @@ void LimeSDROutputGUI::on_swInterp_currentIndexChanged(int index)
void LimeSDROutputGUI::on_lpf_changed(quint64 value)
{
m_settings.m_lpfBW = value * 1000;
checkLPF();
sendSettings();
}

Expand Down
1 change: 1 addition & 0 deletions plugins/samplesink/limesdroutput/limesdroutputgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class LimeSDROutputGUI : public DeviceGUI {
void setCenterFrequencySetting(uint64_t kHzValue);
void sendSettings();
void updateSampleRateAndFrequency();
void checkLPF();
void updateDACRate();
void updateFrequencyLimits();
void blockApplySettings(bool block);
Expand Down
29 changes: 21 additions & 8 deletions plugins/samplesink/limesdroutput/limesdroutputgui.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>360</width>
<height>209</height>
<height>230</height>
</rect>
</property>
<property name="sizePolicy">
Expand All @@ -19,7 +19,7 @@
<property name="minimumSize">
<size>
<width>360</width>
<height>209</height>
<height>230</height>
</size>
</property>
<property name="maximumSize">
Expand Down Expand Up @@ -831,6 +831,19 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="calibrationLabel">
<property name="toolTip">
<string>Red if calibration failed (check log for error)</string>
</property>
<property name="styleSheet">
<string notr="true">background:rgb(79,79,79);</string>
</property>
<property name="text">
<string>C</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="streamLinkRateText">
<property name="minimumSize">
Expand Down Expand Up @@ -934,12 +947,6 @@ QToolTip{background-color: white; color: black;}</string>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ValueDial</class>
<extends>QWidget</extends>
<header>gui/valuedial.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
Expand All @@ -951,6 +958,12 @@ QToolTip{background-color: white; color: black;}</string>
<header>gui/valuedialz.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ValueDial</class>
<extends>QWidget</extends>
<header>gui/valuedial.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>TransverterButton</class>
<extends>QPushButton</extends>
Expand Down
1 change: 1 addition & 0 deletions plugins/samplesink/limesdroutput/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ This label turns green when status can be obtained from the current stream. Usua
- **U**: turns red if stream experiences underruns
- **O**: turns red if stream experiences overruns
- **P**: turns red if stream experiences packet drop outs
- **C**: turns red if calibration fails

<h3>18: Stream global (all Tx) throughput in MB/s</h3>

Expand Down
1 change: 1 addition & 0 deletions plugins/samplesource/fileinput/fileinputgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class FileInputGUI : public DeviceGUI {
void displayTime();
void sendSettings();
void updateSampleRateAndFrequency();
void checkLPF();
void configureFileName();
void updateWithAcquisition();
void updateWithStreamData();
Expand Down
16 changes: 9 additions & 7 deletions plugins/samplesource/limesdrinput/limesdrinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgGetStreamInfo, Message)
MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgGetDeviceInfo, Message)
MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgReportStreamInfo, Message)
MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgStartStop, Message)
MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgCalibrationResult, Message)

LimeSDRInput::LimeSDRInput(DeviceAPI *deviceAPI) :
m_deviceAPI(deviceAPI),
Expand Down Expand Up @@ -1227,19 +1228,20 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc

if (doCalibration)
{
double bw = std::min((double)m_settings.m_devSampleRate, 2500000.0); // Min supported calibration bandwidth is 2.5MHz
if (LMS_Calibrate(m_deviceShared.m_deviceParams->getDevice(),
double bw = std::max((double)m_settings.m_devSampleRate, 2500000.0); // Min supported calibration bandwidth is 2.5MHz
bool calibrationOK = LMS_Calibrate(m_deviceShared.m_deviceParams->getDevice(),
LMS_CH_RX,
m_deviceShared.m_channel,
bw,
0) != 0)
{
0) == 0;
if (!calibrationOK) {
qCritical("LimeSDRInput::applySettings: calibration failed on Rx channel %d", m_deviceShared.m_channel);
}
else
{
} else {
qDebug("LimeSDRInput::applySettings: calibration successful on Rx channel %d", m_deviceShared.m_channel);
}
if (m_guiMessageQueue) {
m_guiMessageQueue->push(MsgCalibrationResult::create(calibrationOK));
}
}

if (doLPCalibration)
Expand Down
19 changes: 19 additions & 0 deletions plugins/samplesource/limesdrinput/limesdrinput.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,25 @@ class LimeSDRInput : public DeviceSampleSource
{ }
};

class MsgCalibrationResult : public Message {
MESSAGE_CLASS_DECLARATION

public:
bool getSuccess() const { return m_success; }

static MsgCalibrationResult* create(bool success) {
return new MsgCalibrationResult(success);
}

protected:
bool m_success;

MsgCalibrationResult(bool success) :
Message(),
m_success(success)
{ }
};

LimeSDRInput(DeviceAPI *deviceAPI);
virtual ~LimeSDRInput();
virtual void destroy();
Expand Down
37 changes: 37 additions & 0 deletions plugins/samplesource/limesdrinput/limesdrinputgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@ bool LimeSDRInputGUI::handleMessage(const Message& message)

return true;
}
else if (LimeSDRInput::MsgCalibrationResult::match(message))
{
LimeSDRInput::MsgCalibrationResult& report = (LimeSDRInput::MsgCalibrationResult&) message;

if (report.getSuccess()) {
ui->calibrationLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }");
} else {
ui->calibrationLabel->setStyleSheet("QLabel { background-color : red; }");
}
}
else if (LimeSDRInput::MsgReportStreamInfo::match(message))
{
LimeSDRInput::MsgReportStreamInfo& report = (LimeSDRInput::MsgReportStreamInfo&) message;
Expand Down Expand Up @@ -322,6 +332,32 @@ void LimeSDRInputGUI::updateSampleRateAndFrequency()
m_deviceUISet->getSpectrum()->setSampleRate(m_sampleRate);
m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency);
displaySampleRate();
checkLPF();
}

// Check if LPF BW is set wide enough when up-converting using NCO
void LimeSDRInputGUI::checkLPF()
{
bool highlightLPFLabel = false;
int64_t centerFrequency = m_settings.m_centerFrequency;
if (m_settings.m_ncoEnable) {
centerFrequency += m_settings.m_ncoFrequency;
}
if (centerFrequency < 30000000)
{
int64_t requiredBW = 30000000 - centerFrequency;
highlightLPFLabel = m_settings.m_lpfBW < requiredBW;
}
if (highlightLPFLabel)
{
ui->lpfLabel->setStyleSheet("QLabel { background-color : red; }");
ui->lpfLabel->setToolTip("LPF BW is too low for selected center frequency");
}
else
{
ui->lpfLabel->setStyleSheet("QLabel { background-color: rgb(64, 64, 64); }");
ui->lpfLabel->setToolTip("");
}
}

void LimeSDRInputGUI::displaySampleRate()
Expand Down Expand Up @@ -619,6 +655,7 @@ void LimeSDRInputGUI::on_swDecim_currentIndexChanged(int index)
void LimeSDRInputGUI::on_lpf_changed(quint64 value)
{
m_settings.m_lpfBW = value * 1000;
checkLPF();
sendSettings();
}

Expand Down
1 change: 1 addition & 0 deletions plugins/samplesource/limesdrinput/limesdrinputgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class LimeSDRInputGUI : public DeviceGUI {
void setCenterFrequencySetting(uint64_t kHzValue);
void sendSettings();
void updateSampleRateAndFrequency();
void checkLPF();
void updateADCRate();
void updateFrequencyLimits();
void blockApplySettings(bool block);
Expand Down
Loading