mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-11-29 03:14:16 -05:00
BladeRF2 and Interferometer: MO operations fixes
This commit is contained in:
parent
d0b64daa4a
commit
235efdceec
@ -84,13 +84,13 @@ void Interferometer::setScopeSink(BasebandSampleSink *scopeSink)
|
||||
m_sink->setScopeSink(scopeSink);
|
||||
}
|
||||
|
||||
void Interferometer::start()
|
||||
void Interferometer::startSinks()
|
||||
{
|
||||
m_sink->reset();
|
||||
m_thread->start();
|
||||
}
|
||||
|
||||
void Interferometer::stop()
|
||||
void Interferometer::stopSinks()
|
||||
{
|
||||
m_thread->exit();
|
||||
m_thread->wait();
|
||||
|
||||
@ -89,8 +89,10 @@ public:
|
||||
virtual ~Interferometer();
|
||||
virtual void destroy() { delete this; }
|
||||
|
||||
virtual void start(); //!< thread start()
|
||||
virtual void stop(); //!< thread exit() and wait()
|
||||
virtual void startSinks(); //!< thread start()
|
||||
virtual void stopSinks(); //!< thread exit() and wait()
|
||||
virtual void startSources() {}
|
||||
virtual void stopSources() {}
|
||||
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, unsigned int sinkIndex);
|
||||
virtual void pull(Sample& sample, unsigned int sourceIndex);
|
||||
virtual bool handleMessage(const Message& cmd); //!< Processing of a message. Returns true if message has actually been processed
|
||||
|
||||
@ -51,7 +51,6 @@ BladeRF2MIMO::BladeRF2MIMO(DeviceAPI *deviceAPI) :
|
||||
m_sourceThread(nullptr),
|
||||
m_sinkThread(nullptr),
|
||||
m_deviceDescription("BladeRF2MIMO"),
|
||||
m_startStopRxElseTx(true),
|
||||
m_runningRx(false),
|
||||
m_runningTx(false),
|
||||
m_dev(nullptr),
|
||||
@ -147,30 +146,19 @@ void BladeRF2MIMO::init()
|
||||
m_fileSinks.push_back(new FileRecord(QString("test_1_%1.sdriq").arg(m_deviceAPI->getDeviceUID())));
|
||||
m_deviceAPI->addAncillarySink(m_fileSinks[0], 0);
|
||||
m_deviceAPI->addAncillarySink(m_fileSinks[1], 1);
|
||||
applySettings(m_settings, true);
|
||||
}
|
||||
|
||||
bool BladeRF2MIMO::start()
|
||||
bool BladeRF2MIMO::startRx()
|
||||
{
|
||||
qDebug("BladeRF2MIMO::startRx");
|
||||
|
||||
if (!m_open)
|
||||
{
|
||||
qCritical("BladeRF2MIMO::start: device could not be opened");
|
||||
qCritical("BladeRF2MIMO::startRx: device was not opened");
|
||||
return false;
|
||||
}
|
||||
|
||||
applySettings(m_settings, true);
|
||||
|
||||
if (m_startStopRxElseTx) {
|
||||
startRx();
|
||||
} else {
|
||||
startTx();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BladeRF2MIMO::startRx()
|
||||
{
|
||||
qDebug("BladeRF2MIMO::startRx");
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
|
||||
if (m_runningRx) {
|
||||
@ -193,11 +181,20 @@ void BladeRF2MIMO::startRx()
|
||||
m_sourceThread->startWork();
|
||||
mutexLocker.unlock();
|
||||
m_runningRx = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BladeRF2MIMO::startTx()
|
||||
bool BladeRF2MIMO::startTx()
|
||||
{
|
||||
qDebug("BladeRF2MIMO::startTx");
|
||||
|
||||
if (!m_open)
|
||||
{
|
||||
qCritical("BladeRF2MIMO::startRx: device was not opened");
|
||||
return false;
|
||||
}
|
||||
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
|
||||
if (m_runningTx) {
|
||||
@ -212,23 +209,16 @@ void BladeRF2MIMO::startTx()
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if (!m_dev->openRx(i)) {
|
||||
qCritical("BladeRF2MIMO::startTx: Rx channel %u cannot be enabled", i);
|
||||
if (!m_dev->openTx(i)) {
|
||||
qCritical("BladeRF2MIMO::startTx: Tx channel %u cannot be enabled", i);
|
||||
}
|
||||
}
|
||||
|
||||
m_sourceThread->startWork();
|
||||
m_sinkThread->startWork();
|
||||
mutexLocker.unlock();
|
||||
m_runningRx = true;
|
||||
}
|
||||
m_runningTx = true;
|
||||
|
||||
void BladeRF2MIMO::stop()
|
||||
{
|
||||
if (m_startStopRxElseTx) {
|
||||
stopRx();
|
||||
} else {
|
||||
stopTx();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void BladeRF2MIMO::stopRx()
|
||||
@ -406,22 +396,17 @@ bool BladeRF2MIMO::handleMessage(const Message& message)
|
||||
<< " " << (cmd.getRxElseTx() ? "Rx" : "Tx")
|
||||
<< " MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
|
||||
|
||||
m_startStopRxElseTx = cmd.getRxElseTx();
|
||||
bool startStopRxElseTx = cmd.getRxElseTx();
|
||||
|
||||
if (cmd.getStartStop()) // start engine if not started yet
|
||||
if (cmd.getStartStop())
|
||||
{
|
||||
if ((m_deviceAPI->state() == DeviceAPI::StNotStarted) || (m_deviceAPI->state() == DeviceAPI::StIdle))
|
||||
{
|
||||
if (m_deviceAPI->initDeviceEngine()) {
|
||||
m_deviceAPI->startDeviceEngine();
|
||||
}
|
||||
if (m_deviceAPI->initDeviceEngine(startStopRxElseTx ? 0 : 1)) {
|
||||
m_deviceAPI->startDeviceEngine(startStopRxElseTx ? 0 : 1);
|
||||
}
|
||||
}
|
||||
else // stop engine if the other part is not running
|
||||
else
|
||||
{
|
||||
if ((m_startStopRxElseTx && !m_runningTx) || (!m_startStopRxElseTx && m_runningRx)) {
|
||||
m_deviceAPI->stopDeviceEngine();
|
||||
}
|
||||
m_deviceAPI->stopDeviceEngine(startStopRxElseTx ? 0 : 1);
|
||||
}
|
||||
|
||||
if (m_settings.m_useReverseAPI) {
|
||||
@ -738,6 +723,7 @@ bool BladeRF2MIMO::applySettings(const BladeRF2MIMOSettings& settings, bool forc
|
||||
|| (m_settings.m_txTransverterMode != settings.m_txTransverterMode)
|
||||
|| (m_settings.m_txTransverterDeltaFrequency != settings.m_txTransverterDeltaFrequency)
|
||||
|| (m_settings.m_fcPosTx != settings.m_fcPosTx)
|
||||
|| (m_settings.m_log2Interp != settings.m_log2Interp)
|
||||
|| (m_settings.m_LOppmTenths != settings.m_LOppmTenths)
|
||||
|| (m_settings.m_devSampleRate != settings.m_devSampleRate) || force)
|
||||
{
|
||||
@ -869,9 +855,9 @@ bool BladeRF2MIMO::applySettings(const BladeRF2MIMOSettings& settings, bool forc
|
||||
if (forwardChangeTxDSP)
|
||||
{
|
||||
int sampleRate = settings.m_devSampleRate/(1<<settings.m_log2Interp);
|
||||
DSPMIMOSignalNotification *notif0 = new DSPMIMOSignalNotification(sampleRate, settings.m_rxCenterFrequency, false, 0);
|
||||
DSPMIMOSignalNotification *notif0 = new DSPMIMOSignalNotification(sampleRate, settings.m_txCenterFrequency, false, 0);
|
||||
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif0);
|
||||
DSPMIMOSignalNotification *notif1 = new DSPMIMOSignalNotification(sampleRate, settings.m_rxCenterFrequency, false, 1);
|
||||
DSPMIMOSignalNotification *notif1 = new DSPMIMOSignalNotification(sampleRate, settings.m_txCenterFrequency, false, 1);
|
||||
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif1);
|
||||
}
|
||||
|
||||
|
||||
@ -148,8 +148,10 @@ public:
|
||||
virtual void destroy();
|
||||
|
||||
virtual void init();
|
||||
virtual bool start();
|
||||
virtual void stop();
|
||||
virtual bool startRx();
|
||||
virtual void stopRx();
|
||||
virtual bool startTx();
|
||||
virtual void stopTx();
|
||||
|
||||
virtual QByteArray serialize() const;
|
||||
virtual bool deserialize(const QByteArray& data);
|
||||
@ -223,7 +225,6 @@ private:
|
||||
BladeRF2MIThread* m_sourceThread;
|
||||
BladeRF2MOThread* m_sinkThread;
|
||||
QString m_deviceDescription;
|
||||
bool m_startStopRxElseTx;
|
||||
bool m_runningRx;
|
||||
bool m_runningTx;
|
||||
QNetworkAccessManager *m_networkManager;
|
||||
@ -235,10 +236,6 @@ private:
|
||||
|
||||
bool openDevice();
|
||||
void closeDevice();
|
||||
void startRx();
|
||||
void stopRx();
|
||||
void startTx();
|
||||
void stopTx();
|
||||
|
||||
bool applySettings(const BladeRF2MIMOSettings& settings, bool force);
|
||||
bool setRxDeviceCenterFrequency(struct bladerf *dev, quint64 freq_hz, int loPpmTenths);
|
||||
|
||||
@ -55,10 +55,12 @@ BladeRF2MIMOGui::BladeRF2MIMOGui(DeviceUISet *deviceUISet, QWidget* parent) :
|
||||
m_forceSettings(true),
|
||||
m_sampleMIMO(nullptr),
|
||||
m_tickCount(0),
|
||||
m_deviceSampleRate(3072000),
|
||||
m_rxBasebandSampleRate(3072000),
|
||||
m_txBasebandSampleRate(3072000),
|
||||
m_rxDeviceCenterFrequency(435000*1000),
|
||||
m_txDeviceCenterFrequency(435000*1000),
|
||||
m_lastEngineState(DeviceAPI::StNotStarted),
|
||||
m_lastRxEngineState(DeviceAPI::StNotStarted),
|
||||
m_lastTxEngineState(DeviceAPI::StNotStarted),
|
||||
m_sampleRateMode(true)
|
||||
{
|
||||
qDebug("BladeRF2MIMOGui::BladeRF2MIMOGui");
|
||||
@ -92,6 +94,8 @@ BladeRF2MIMOGui::BladeRF2MIMOGui(DeviceUISet *deviceUISet, QWidget* parent) :
|
||||
|
||||
CRightClickEnabler *startStopRightClickEnabler = new CRightClickEnabler(ui->startStopRx);
|
||||
connect(startStopRightClickEnabler, SIGNAL(rightClick(const QPoint &)), this, SLOT(openDeviceSettingsDialog(const QPoint &)));
|
||||
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
BladeRF2MIMOGui::~BladeRF2MIMOGui()
|
||||
@ -140,12 +144,15 @@ QByteArray BladeRF2MIMOGui::serialize() const
|
||||
|
||||
bool BladeRF2MIMOGui::deserialize(const QByteArray& data)
|
||||
{
|
||||
if(m_settings.deserialize(data)) {
|
||||
if (m_settings.deserialize(data))
|
||||
{
|
||||
displaySettings();
|
||||
m_forceSettings = true;
|
||||
sendSettings();
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
resetToDefaults();
|
||||
return false;
|
||||
}
|
||||
@ -314,11 +321,15 @@ bool BladeRF2MIMOGui::handleMessage(const Message& message)
|
||||
const DSPMIMOSignalNotification& notif = (const DSPMIMOSignalNotification&) message;
|
||||
int istream = notif.getIndex();
|
||||
bool sourceOrSink = notif.getSourceOrSink();
|
||||
m_deviceSampleRate = notif.getSampleRate();
|
||||
|
||||
if (sourceOrSink) {
|
||||
if (sourceOrSink)
|
||||
{
|
||||
m_rxBasebandSampleRate = notif.getSampleRate();
|
||||
m_rxDeviceCenterFrequency = notif.getCenterFrequency();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
m_txBasebandSampleRate = notif.getSampleRate();
|
||||
m_txDeviceCenterFrequency = notif.getCenterFrequency();
|
||||
}
|
||||
|
||||
@ -370,11 +381,14 @@ void BladeRF2MIMOGui::updateHardware()
|
||||
|
||||
void BladeRF2MIMOGui::updateSampleRateAndFrequency()
|
||||
{
|
||||
m_deviceUISet->getSpectrum()->setSampleRate(m_deviceSampleRate);
|
||||
|
||||
if (m_rxElseTx) {
|
||||
if (m_spectrumRxElseTx)
|
||||
{
|
||||
m_deviceUISet->getSpectrum()->setSampleRate(m_rxBasebandSampleRate);
|
||||
m_deviceUISet->getSpectrum()->setCenterFrequency(m_rxDeviceCenterFrequency);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
m_deviceUISet->getSpectrum()->setSampleRate(m_txBasebandSampleRate);
|
||||
m_deviceUISet->getSpectrum()->setCenterFrequency(m_txDeviceCenterFrequency);
|
||||
}
|
||||
}
|
||||
@ -403,7 +417,8 @@ void BladeRF2MIMOGui::on_streamIndex_currentIndexChanged(int index)
|
||||
|
||||
void BladeRF2MIMOGui::on_spectrumSide_currentIndexChanged(int index)
|
||||
{
|
||||
m_spectrumRxElseTx = index == 0;
|
||||
m_spectrumRxElseTx = (index == 0);
|
||||
updateSampleRateAndFrequency();
|
||||
// TODO
|
||||
}
|
||||
|
||||
@ -695,46 +710,56 @@ void BladeRF2MIMOGui::setCenterFrequencySetting(uint64_t kHzValue)
|
||||
|
||||
void BladeRF2MIMOGui::updateStatus()
|
||||
{
|
||||
int state = m_deviceUISet->m_deviceAPI->state();
|
||||
int stateRx = m_deviceUISet->m_deviceAPI->state(0);
|
||||
int stateTx = m_deviceUISet->m_deviceAPI->state(1);
|
||||
|
||||
if (m_lastEngineState != state)
|
||||
if (m_lastRxEngineState != stateRx)
|
||||
{
|
||||
switch(state)
|
||||
qDebug("BladeRF2MIMOGui::updateStatus: stateRx: %d", (int) stateRx);
|
||||
switch(stateRx)
|
||||
{
|
||||
case DeviceAPI::StNotStarted:
|
||||
ui->startStopRx->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
||||
ui->startStopTx->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
||||
break;
|
||||
case DeviceAPI::StIdle:
|
||||
ui->startStopRx->setStyleSheet("QToolButton { background-color : blue; }");
|
||||
ui->startStopTx->setStyleSheet("QToolButton { background-color : blue; }");
|
||||
break;
|
||||
case DeviceAPI::StRunning:
|
||||
{
|
||||
if (m_sampleMIMO->getRxRunning()) {
|
||||
ui->startStopRx->setStyleSheet("QToolButton { background-color : green; }");
|
||||
} else {
|
||||
ui->startStopRx->setStyleSheet("QToolButton { background-color : blue; }");
|
||||
}
|
||||
if (m_sampleMIMO->getTxRunning()) {
|
||||
ui->startStopTx->setStyleSheet("QToolButton { background-color : green; }");
|
||||
} else {
|
||||
ui->startStopTx->setStyleSheet("QToolButton { background-color : blue; }");
|
||||
}
|
||||
}
|
||||
ui->startStopRx->setStyleSheet("QToolButton { background-color : green; }");
|
||||
break;
|
||||
case DeviceAPI::StError:
|
||||
if (m_rxElseTx) {
|
||||
ui->startStopRx->setStyleSheet("QToolButton { background-color : red; }");
|
||||
} else {
|
||||
ui->startStopTx->setStyleSheet("QToolButton { background-color : red; }");
|
||||
}
|
||||
QMessageBox::information(this, tr("Message"), m_deviceUISet->m_deviceAPI->errorMessage());
|
||||
ui->startStopRx->setStyleSheet("QToolButton { background-color : red; }");
|
||||
QMessageBox::information(this, tr("Message"), m_deviceUISet->m_deviceAPI->errorMessage(0));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m_lastEngineState = state;
|
||||
m_lastRxEngineState = stateRx;
|
||||
}
|
||||
|
||||
if (m_lastTxEngineState != stateTx)
|
||||
{
|
||||
qDebug("BladeRF2MIMOGui::updateStatus: stateTx: %d", (int) stateTx);
|
||||
switch(stateTx)
|
||||
{
|
||||
case DeviceAPI::StNotStarted:
|
||||
ui->startStopTx->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
||||
break;
|
||||
case DeviceAPI::StIdle:
|
||||
ui->startStopTx->setStyleSheet("QToolButton { background-color : blue; }");
|
||||
break;
|
||||
case DeviceAPI::StRunning:
|
||||
ui->startStopTx->setStyleSheet("QToolButton { background-color : green; }");
|
||||
break;
|
||||
case DeviceAPI::StError:
|
||||
ui->startStopTx->setStyleSheet("QToolButton { background-color : red; }");
|
||||
QMessageBox::information(this, tr("Message"), m_deviceUISet->m_deviceAPI->errorMessage(1));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m_lastTxEngineState = stateTx;
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,10 +66,12 @@ private:
|
||||
bool m_forceSettings;
|
||||
BladeRF2MIMO* m_sampleMIMO;
|
||||
std::size_t m_tickCount;
|
||||
int m_deviceSampleRate;
|
||||
int m_rxBasebandSampleRate;
|
||||
int m_txBasebandSampleRate;
|
||||
quint64 m_rxDeviceCenterFrequency; //!< Center frequency in Rx device
|
||||
quint64 m_txDeviceCenterFrequency; //!< Center frequency in Tx device
|
||||
int m_lastEngineState;
|
||||
int m_lastRxEngineState;
|
||||
int m_lastTxEngineState;
|
||||
MessageQueue m_inputMessageQueue;
|
||||
|
||||
bool m_sampleRateMode;
|
||||
|
||||
@ -278,6 +278,12 @@
|
||||
<layout class="QHBoxLayout" name="deviceRateLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="deviceRateText">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>I/Q sample rate kS/s</string>
|
||||
</property>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user