mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 17:58:43 -05:00
LimeSDR still unreliable but comitting as is
This commit is contained in:
parent
e9af2f6dff
commit
124404aa18
@ -163,43 +163,43 @@ bool LimeSDROutput::openDevice()
|
|||||||
|
|
||||||
// acquire the channel
|
// acquire the channel
|
||||||
|
|
||||||
if (LMS_EnableChannel(m_deviceShared.m_deviceParams->getDevice(), LMS_CH_TX, m_deviceShared.m_channel, true) != 0)
|
// if (LMS_EnableChannel(m_deviceShared.m_deviceParams->getDevice(), LMS_CH_TX, m_deviceShared.m_channel, true) != 0)
|
||||||
{
|
// {
|
||||||
qCritical("LimeSDROutput::acquireChannel: cannot enable Tx channel %d", m_deviceShared.m_channel);
|
// qCritical("LimeSDROutput::acquireChannel: cannot enable Tx channel %d", m_deviceShared.m_channel);
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
qDebug("LimeSDROutput::acquireChannel: Tx channel %d enabled", m_deviceShared.m_channel);
|
// qDebug("LimeSDROutput::acquireChannel: Tx channel %d enabled", m_deviceShared.m_channel);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// set up the stream
|
// set up the stream
|
||||||
|
|
||||||
m_streamId.channel = m_deviceShared.m_channel; // channel number
|
// m_streamId.channel = m_deviceShared.m_channel; // channel number
|
||||||
m_streamId.fifoSize = 512 * 1024; // fifo size in samples (SR / 10 take ~5MS/s)
|
// m_streamId.fifoSize = 512 * 1024; // fifo size in samples (SR / 10 take ~5MS/s)
|
||||||
m_streamId.throughputVsLatency = 0.0; // optimize for min latency
|
// m_streamId.throughputVsLatency = 0.0; // optimize for min latency
|
||||||
m_streamId.isTx = true; // TX channel
|
// m_streamId.isTx = true; // TX channel
|
||||||
m_streamId.dataFmt = lms_stream_t::LMS_FMT_I12; // 12-bit integers
|
// m_streamId.dataFmt = lms_stream_t::LMS_FMT_I12; // 12-bit integers
|
||||||
|
//
|
||||||
|
// suspendRxBuddies();
|
||||||
|
// suspendTxBuddies();
|
||||||
|
//
|
||||||
|
// if (LMS_SetupStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId) != 0)
|
||||||
|
// {
|
||||||
|
// qCritical("LimeSDROutput::acquireChannel: cannot setup the stream on Tx channel %d", m_deviceShared.m_channel);
|
||||||
|
// resumeTxBuddies();
|
||||||
|
// resumeRxBuddies();
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// qDebug("LimeSDROutput::acquireChannel: stream set up on Tx channel %d", m_deviceShared.m_channel);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// resumeTxBuddies();
|
||||||
|
// resumeRxBuddies();
|
||||||
|
|
||||||
suspendRxBuddies();
|
// m_channelAcquired = true;
|
||||||
suspendTxBuddies();
|
|
||||||
|
|
||||||
if (LMS_SetupStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId) != 0)
|
|
||||||
{
|
|
||||||
qCritical("LimeSDROutput::acquireChannel: cannot setup the stream on Tx channel %d", m_deviceShared.m_channel);
|
|
||||||
resumeTxBuddies();
|
|
||||||
resumeRxBuddies();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
qDebug("LimeSDROutput::acquireChannel: stream set up on Tx channel %d", m_deviceShared.m_channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
resumeTxBuddies();
|
|
||||||
resumeRxBuddies();
|
|
||||||
|
|
||||||
m_channelAcquired = true;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -209,6 +209,8 @@ void LimeSDROutput::suspendRxBuddies()
|
|||||||
const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
|
const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
|
||||||
std::vector<DeviceSourceAPI*>::const_iterator itSource = sourceBuddies.begin();
|
std::vector<DeviceSourceAPI*>::const_iterator itSource = sourceBuddies.begin();
|
||||||
|
|
||||||
|
qDebug("LimeSDROutput::suspendRxBuddies (%lu)", sourceBuddies.size());
|
||||||
|
|
||||||
for (; itSource != sourceBuddies.end(); ++itSource)
|
for (; itSource != sourceBuddies.end(); ++itSource)
|
||||||
{
|
{
|
||||||
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSource)->getBuddySharedPtr();
|
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSource)->getBuddySharedPtr();
|
||||||
@ -230,6 +232,8 @@ void LimeSDROutput::suspendTxBuddies()
|
|||||||
const std::vector<DeviceSinkAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
|
const std::vector<DeviceSinkAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
|
||||||
std::vector<DeviceSinkAPI*>::const_iterator itSink = sinkBuddies.begin();
|
std::vector<DeviceSinkAPI*>::const_iterator itSink = sinkBuddies.begin();
|
||||||
|
|
||||||
|
qDebug("LimeSDROutput::suspendTxBuddies (%lu)", sinkBuddies.size());
|
||||||
|
|
||||||
for (; itSink != sinkBuddies.end(); ++itSink)
|
for (; itSink != sinkBuddies.end(); ++itSink)
|
||||||
{
|
{
|
||||||
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSink)->getBuddySharedPtr();
|
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSink)->getBuddySharedPtr();
|
||||||
@ -251,6 +255,8 @@ void LimeSDROutput::resumeRxBuddies()
|
|||||||
const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
|
const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
|
||||||
std::vector<DeviceSourceAPI*>::const_iterator itSource = sourceBuddies.begin();
|
std::vector<DeviceSourceAPI*>::const_iterator itSource = sourceBuddies.begin();
|
||||||
|
|
||||||
|
qDebug("LimeSDROutput::resumeRxBuddies (%lu)", sourceBuddies.size());
|
||||||
|
|
||||||
for (; itSource != sourceBuddies.end(); ++itSource)
|
for (; itSource != sourceBuddies.end(); ++itSource)
|
||||||
{
|
{
|
||||||
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSource)->getBuddySharedPtr();
|
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSource)->getBuddySharedPtr();
|
||||||
@ -266,6 +272,8 @@ void LimeSDROutput::resumeTxBuddies()
|
|||||||
const std::vector<DeviceSinkAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
|
const std::vector<DeviceSinkAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
|
||||||
std::vector<DeviceSinkAPI*>::const_iterator itSink = sinkBuddies.begin();
|
std::vector<DeviceSinkAPI*>::const_iterator itSink = sinkBuddies.begin();
|
||||||
|
|
||||||
|
qDebug("LimeSDROutput::resumeTxBuddies (%lu)", sinkBuddies.size());
|
||||||
|
|
||||||
for (; itSink != sinkBuddies.end(); ++itSink)
|
for (; itSink != sinkBuddies.end(); ++itSink)
|
||||||
{
|
{
|
||||||
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSink)->getBuddySharedPtr();
|
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSink)->getBuddySharedPtr();
|
||||||
@ -286,23 +294,23 @@ void LimeSDROutput::closeDevice()
|
|||||||
|
|
||||||
// destroy the stream
|
// destroy the stream
|
||||||
|
|
||||||
suspendRxBuddies();
|
// suspendRxBuddies();
|
||||||
suspendTxBuddies();
|
// suspendTxBuddies();
|
||||||
|
//
|
||||||
LMS_DestroyStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId);
|
// LMS_DestroyStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId);
|
||||||
m_streamId.handle = 0;
|
// m_streamId.handle = 0;
|
||||||
|
//
|
||||||
resumeTxBuddies();
|
// resumeTxBuddies();
|
||||||
resumeRxBuddies();
|
// resumeRxBuddies();
|
||||||
|
|
||||||
// release the channel
|
// release the channel
|
||||||
|
|
||||||
if (LMS_EnableChannel(m_deviceShared.m_deviceParams->getDevice(), LMS_CH_TX, m_deviceShared.m_channel, false) != 0)
|
// if (LMS_EnableChannel(m_deviceShared.m_deviceParams->getDevice(), LMS_CH_TX, m_deviceShared.m_channel, false) != 0)
|
||||||
{
|
// {
|
||||||
qWarning("LimeSDROutput::releaseChannel: cannot disable Tx channel %d", m_deviceShared.m_channel);
|
// qWarning("LimeSDROutput::releaseChannel: cannot disable Tx channel %d", m_deviceShared.m_channel);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
m_channelAcquired = false;
|
// m_channelAcquired = false;
|
||||||
|
|
||||||
// No buddies so effectively close the device
|
// No buddies so effectively close the device
|
||||||
|
|
||||||
@ -336,8 +344,8 @@ bool LimeSDROutput::acquireChannel()
|
|||||||
// set up the stream
|
// set up the stream
|
||||||
|
|
||||||
m_streamId.channel = m_deviceShared.m_channel; // channel number
|
m_streamId.channel = m_deviceShared.m_channel; // channel number
|
||||||
m_streamId.fifoSize = 512 * 1024; // fifo size in samples (SR / 10 take ~5MS/s)
|
m_streamId.fifoSize = 1024 * 1024; // fifo size in samples (SR / 10 take ~5MS/s)
|
||||||
m_streamId.throughputVsLatency = 0.0; // optimize for min latency
|
m_streamId.throughputVsLatency = 0.5; // optimize for min latency
|
||||||
m_streamId.isTx = true; // TX channel
|
m_streamId.isTx = true; // TX channel
|
||||||
m_streamId.dataFmt = lms_stream_t::LMS_FMT_I12; // 12-bit integers
|
m_streamId.dataFmt = lms_stream_t::LMS_FMT_I12; // 12-bit integers
|
||||||
|
|
||||||
@ -353,10 +361,11 @@ bool LimeSDROutput::acquireChannel()
|
|||||||
qDebug("LimeSDROutput::acquireChannel: stream set up on Tx channel %d", m_deviceShared.m_channel);
|
qDebug("LimeSDROutput::acquireChannel: stream set up on Tx channel %d", m_deviceShared.m_channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_channelAcquired = true;
|
|
||||||
resumeTxBuddies();
|
resumeTxBuddies();
|
||||||
resumeRxBuddies();
|
resumeRxBuddies();
|
||||||
|
|
||||||
|
m_channelAcquired = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,7 +375,16 @@ void LimeSDROutput::releaseChannel()
|
|||||||
suspendTxBuddies();
|
suspendTxBuddies();
|
||||||
|
|
||||||
// destroy the stream
|
// destroy the stream
|
||||||
LMS_DestroyStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId);
|
|
||||||
|
if (LMS_DestroyStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId) != 0)
|
||||||
|
{
|
||||||
|
qWarning("LimeSDROutput::releaseChannel: cannot destroy the stream on Tx channel %d", m_deviceShared.m_channel);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("LimeSDROutput::releaseChannel: stream destroyed on Tx channel %d", m_deviceShared.m_channel);
|
||||||
|
}
|
||||||
|
|
||||||
m_streamId.handle = 0;
|
m_streamId.handle = 0;
|
||||||
|
|
||||||
// release the channel
|
// release the channel
|
||||||
@ -375,10 +393,15 @@ void LimeSDROutput::releaseChannel()
|
|||||||
{
|
{
|
||||||
qWarning("LimeSDROutput::releaseChannel: cannot disable Tx channel %d", m_deviceShared.m_channel);
|
qWarning("LimeSDROutput::releaseChannel: cannot disable Tx channel %d", m_deviceShared.m_channel);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("LimeSDROutput::releaseChannel: Tx channel %d released", m_deviceShared.m_channel);
|
||||||
|
}
|
||||||
|
|
||||||
m_channelAcquired = false;
|
|
||||||
resumeTxBuddies();
|
resumeTxBuddies();
|
||||||
resumeRxBuddies();
|
resumeRxBuddies();
|
||||||
|
|
||||||
|
m_channelAcquired = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LimeSDROutput::start()
|
bool LimeSDROutput::start()
|
||||||
@ -389,10 +412,10 @@ bool LimeSDROutput::start()
|
|||||||
|
|
||||||
if (m_running) { stop(); }
|
if (m_running) { stop(); }
|
||||||
|
|
||||||
// if (!acquireChannel())
|
if (!acquireChannel())
|
||||||
// {
|
{
|
||||||
// return false;
|
return false;
|
||||||
// }
|
}
|
||||||
|
|
||||||
applySettings(m_settings, true);
|
applySettings(m_settings, true);
|
||||||
|
|
||||||
@ -421,6 +444,8 @@ bool LimeSDROutput::start()
|
|||||||
|
|
||||||
void LimeSDROutput::stop()
|
void LimeSDROutput::stop()
|
||||||
{
|
{
|
||||||
|
qDebug("LimeSDROutput::stop");
|
||||||
|
|
||||||
if (m_limeSDROutputThread != 0)
|
if (m_limeSDROutputThread != 0)
|
||||||
{
|
{
|
||||||
m_limeSDROutputThread->stopWork();
|
m_limeSDROutputThread->stopWork();
|
||||||
@ -431,7 +456,7 @@ void LimeSDROutput::stop()
|
|||||||
m_deviceShared.m_thread = 0;
|
m_deviceShared.m_thread = 0;
|
||||||
m_running = false;
|
m_running = false;
|
||||||
|
|
||||||
// releaseChannel();
|
releaseChannel();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString& LimeSDROutput::getDeviceDescription() const
|
const QString& LimeSDROutput::getDeviceDescription() const
|
||||||
@ -665,7 +690,7 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
|
|||||||
(m_settings.m_ncoFrequency != settings.m_ncoFrequency) ||
|
(m_settings.m_ncoFrequency != settings.m_ncoFrequency) ||
|
||||||
(m_settings.m_log2SoftInterp != settings.m_log2SoftInterp) || force)
|
(m_settings.m_log2SoftInterp != settings.m_log2SoftInterp) || force)
|
||||||
{
|
{
|
||||||
suspendOwnThread = true;
|
suspendOwnThread = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// suspend buddies threads or own thread
|
// suspend buddies threads or own thread
|
||||||
|
@ -41,7 +41,8 @@ LimeSDRInput::LimeSDRInput(DeviceSourceAPI *deviceAPI) :
|
|||||||
m_settings(),
|
m_settings(),
|
||||||
m_limeSDRInputThread(0),
|
m_limeSDRInputThread(0),
|
||||||
m_deviceDescription("LimeSDRInput"),
|
m_deviceDescription("LimeSDRInput"),
|
||||||
m_running(false)
|
m_running(false),
|
||||||
|
m_channelAcquired(false)
|
||||||
{
|
{
|
||||||
m_streamId.handle = 0;
|
m_streamId.handle = 0;
|
||||||
suspendRxBuddies();
|
suspendRxBuddies();
|
||||||
@ -180,39 +181,39 @@ bool LimeSDRInput::openDevice()
|
|||||||
|
|
||||||
// acquire the channel
|
// acquire the channel
|
||||||
|
|
||||||
if (LMS_EnableChannel(m_deviceShared.m_deviceParams->getDevice(), LMS_CH_RX, m_deviceShared.m_channel, true) != 0)
|
// if (LMS_EnableChannel(m_deviceShared.m_deviceParams->getDevice(), LMS_CH_RX, m_deviceShared.m_channel, true) != 0)
|
||||||
{
|
// {
|
||||||
qCritical("LimeSDRInput::openDevice: cannot enable Rx channel %d", m_deviceShared.m_channel);
|
// qCritical("LimeSDRInput::openDevice: cannot enable Rx channel %d", m_deviceShared.m_channel);
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
qDebug("LimeSDRInput::openDevice: Rx channel %d enabled", m_deviceShared.m_channel);
|
// qDebug("LimeSDRInput::openDevice: Rx channel %d enabled", m_deviceShared.m_channel);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// set up the stream
|
// set up the stream
|
||||||
|
|
||||||
m_streamId.channel = m_deviceShared.m_channel; //channel number
|
// m_streamId.channel = m_deviceShared.m_channel; //channel number
|
||||||
m_streamId.fifoSize = 1024 * 1024; //fifo size in samples
|
// m_streamId.fifoSize = 1024 * 1024; //fifo size in samples
|
||||||
m_streamId.throughputVsLatency = 1.0; //optimize for max throughput
|
// m_streamId.throughputVsLatency = 1.0; //optimize for max throughput
|
||||||
m_streamId.isTx = false; //RX channel
|
// m_streamId.isTx = false; //RX channel
|
||||||
m_streamId.dataFmt = lms_stream_t::LMS_FMT_I12; //12-bit integers
|
// m_streamId.dataFmt = lms_stream_t::LMS_FMT_I12; //12-bit integers
|
||||||
|
//
|
||||||
suspendRxBuddies();
|
// suspendRxBuddies();
|
||||||
suspendTxBuddies();
|
// suspendTxBuddies();
|
||||||
|
//
|
||||||
if (LMS_SetupStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId) != 0)
|
// if (LMS_SetupStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId) != 0)
|
||||||
{
|
// {
|
||||||
qCritical("LimeSDRInput::start: cannot setup the stream on Rx channel %d", m_deviceShared.m_channel);
|
// qCritical("LimeSDRInput::start: cannot setup the stream on Rx channel %d", m_deviceShared.m_channel);
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
qDebug("LimeSDRInput::start: stream set up on Rx channel %d", m_deviceShared.m_channel);
|
// qDebug("LimeSDRInput::start: stream set up on Rx channel %d", m_deviceShared.m_channel);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
resumeTxBuddies();
|
// resumeTxBuddies();
|
||||||
resumeRxBuddies();
|
// resumeRxBuddies();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -222,6 +223,8 @@ void LimeSDRInput::suspendRxBuddies()
|
|||||||
const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
|
const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
|
||||||
std::vector<DeviceSourceAPI*>::const_iterator itSource = sourceBuddies.begin();
|
std::vector<DeviceSourceAPI*>::const_iterator itSource = sourceBuddies.begin();
|
||||||
|
|
||||||
|
qDebug("LimeSDRInput::suspendRxBuddies (%lu)", sourceBuddies.size());
|
||||||
|
|
||||||
for (; itSource != sourceBuddies.end(); ++itSource)
|
for (; itSource != sourceBuddies.end(); ++itSource)
|
||||||
{
|
{
|
||||||
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSource)->getBuddySharedPtr();
|
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSource)->getBuddySharedPtr();
|
||||||
@ -243,6 +246,8 @@ void LimeSDRInput::suspendTxBuddies()
|
|||||||
const std::vector<DeviceSinkAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
|
const std::vector<DeviceSinkAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
|
||||||
std::vector<DeviceSinkAPI*>::const_iterator itSink = sinkBuddies.begin();
|
std::vector<DeviceSinkAPI*>::const_iterator itSink = sinkBuddies.begin();
|
||||||
|
|
||||||
|
qDebug("LimeSDRInput::suspendTxBuddies (%lu)", sinkBuddies.size());
|
||||||
|
|
||||||
for (; itSink != sinkBuddies.end(); ++itSink)
|
for (; itSink != sinkBuddies.end(); ++itSink)
|
||||||
{
|
{
|
||||||
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSink)->getBuddySharedPtr();
|
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSink)->getBuddySharedPtr();
|
||||||
@ -263,6 +268,8 @@ void LimeSDRInput::resumeRxBuddies()
|
|||||||
const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
|
const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
|
||||||
std::vector<DeviceSourceAPI*>::const_iterator itSource = sourceBuddies.begin();
|
std::vector<DeviceSourceAPI*>::const_iterator itSource = sourceBuddies.begin();
|
||||||
|
|
||||||
|
qDebug("LimeSDRInput::resumeRxBuddies (%lu)", sourceBuddies.size());
|
||||||
|
|
||||||
for (; itSource != sourceBuddies.end(); ++itSource)
|
for (; itSource != sourceBuddies.end(); ++itSource)
|
||||||
{
|
{
|
||||||
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSource)->getBuddySharedPtr();
|
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSource)->getBuddySharedPtr();
|
||||||
@ -278,6 +285,8 @@ void LimeSDRInput::resumeTxBuddies()
|
|||||||
const std::vector<DeviceSinkAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
|
const std::vector<DeviceSinkAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
|
||||||
std::vector<DeviceSinkAPI*>::const_iterator itSink = sinkBuddies.begin();
|
std::vector<DeviceSinkAPI*>::const_iterator itSink = sinkBuddies.begin();
|
||||||
|
|
||||||
|
qDebug("LimeSDRInput::resumeTxBuddies (%lu)", sinkBuddies.size());
|
||||||
|
|
||||||
for (; itSink != sinkBuddies.end(); ++itSink)
|
for (; itSink != sinkBuddies.end(); ++itSink)
|
||||||
{
|
{
|
||||||
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSink)->getBuddySharedPtr();
|
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSink)->getBuddySharedPtr();
|
||||||
@ -296,22 +305,23 @@ void LimeSDRInput::closeDevice()
|
|||||||
|
|
||||||
if (m_running) { stop(); }
|
if (m_running) { stop(); }
|
||||||
|
|
||||||
suspendRxBuddies();
|
|
||||||
suspendTxBuddies();
|
|
||||||
|
|
||||||
// destroy the stream
|
// destroy the stream
|
||||||
LMS_DestroyStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId);
|
|
||||||
m_streamId.handle = 0;
|
|
||||||
|
|
||||||
resumeTxBuddies();
|
// suspendRxBuddies();
|
||||||
resumeRxBuddies();
|
// suspendTxBuddies();
|
||||||
|
//
|
||||||
|
// LMS_DestroyStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId);
|
||||||
|
// m_streamId.handle = 0;
|
||||||
|
//
|
||||||
|
// resumeTxBuddies();
|
||||||
|
// resumeRxBuddies();
|
||||||
|
|
||||||
// release the channel
|
// release the channel
|
||||||
|
|
||||||
if (LMS_EnableChannel(m_deviceShared.m_deviceParams->getDevice(), LMS_CH_RX, m_deviceShared.m_channel, false) != 0)
|
// if (LMS_EnableChannel(m_deviceShared.m_deviceParams->getDevice(), LMS_CH_RX, m_deviceShared.m_channel, false) != 0)
|
||||||
{
|
// {
|
||||||
qWarning("LimeSDRInput::closeDevice: cannot disable Rx channel %d", m_deviceShared.m_channel);
|
// qWarning("LimeSDRInput::closeDevice: cannot disable Rx channel %d", m_deviceShared.m_channel);
|
||||||
}
|
// }
|
||||||
|
|
||||||
m_deviceShared.m_channel = -1;
|
m_deviceShared.m_channel = -1;
|
||||||
|
|
||||||
@ -325,6 +335,85 @@ void LimeSDRInput::closeDevice()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LimeSDRInput::acquireChannel()
|
||||||
|
{
|
||||||
|
suspendRxBuddies();
|
||||||
|
suspendTxBuddies();
|
||||||
|
|
||||||
|
// acquire the channel
|
||||||
|
|
||||||
|
if (LMS_EnableChannel(m_deviceShared.m_deviceParams->getDevice(), LMS_CH_RX, m_deviceShared.m_channel, true) != 0)
|
||||||
|
{
|
||||||
|
qCritical("LimeSDRInput::acquireChannel: cannot enable Rx channel %d", m_deviceShared.m_channel);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("LimeSDRInput::acquireChannel: Rx channel %d enabled", m_deviceShared.m_channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set up the stream
|
||||||
|
|
||||||
|
m_streamId.channel = m_deviceShared.m_channel; // channel number
|
||||||
|
m_streamId.fifoSize = 1024 * 1024; // fifo size in samples (SR / 10 take ~5MS/s)
|
||||||
|
m_streamId.throughputVsLatency = 0.5; // optimize for min latency
|
||||||
|
m_streamId.isTx = false; // RX channel
|
||||||
|
m_streamId.dataFmt = lms_stream_t::LMS_FMT_I12; // 12-bit integers
|
||||||
|
|
||||||
|
if (LMS_SetupStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId) != 0)
|
||||||
|
{
|
||||||
|
qCritical("LimeSDRInput::acquireChannel: cannot setup the stream on Rx channel %d", m_deviceShared.m_channel);
|
||||||
|
resumeTxBuddies();
|
||||||
|
resumeRxBuddies();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("LimeSDRInput::acquireChannel: stream set up on Rx channel %d", m_deviceShared.m_channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
resumeTxBuddies();
|
||||||
|
resumeRxBuddies();
|
||||||
|
|
||||||
|
m_channelAcquired = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LimeSDRInput::releaseChannel()
|
||||||
|
{
|
||||||
|
suspendRxBuddies();
|
||||||
|
suspendTxBuddies();
|
||||||
|
|
||||||
|
// destroy the stream
|
||||||
|
if (LMS_DestroyStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId) != 0)
|
||||||
|
{
|
||||||
|
qWarning("LimeSDRInput::releaseChannel: cannot destroy the stream on Rx channel %d", m_deviceShared.m_channel);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("LimeSDRInput::releaseChannel: stream destroyed on Rx channel %d", m_deviceShared.m_channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_streamId.handle = 0;
|
||||||
|
|
||||||
|
// release the channel
|
||||||
|
|
||||||
|
if (LMS_EnableChannel(m_deviceShared.m_deviceParams->getDevice(), LMS_CH_RX, m_deviceShared.m_channel, false) != 0)
|
||||||
|
{
|
||||||
|
qWarning("LimeSDRInput::releaseChannel: cannot disable Rx channel %d", m_deviceShared.m_channel);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("LimeSDRInput::releaseChannel: Rx channel %d disabled", m_deviceShared.m_channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
resumeTxBuddies();
|
||||||
|
resumeRxBuddies();
|
||||||
|
|
||||||
|
m_channelAcquired = false;
|
||||||
|
}
|
||||||
|
|
||||||
bool LimeSDRInput::start()
|
bool LimeSDRInput::start()
|
||||||
{
|
{
|
||||||
if (!m_deviceShared.m_deviceParams->getDevice()) {
|
if (!m_deviceShared.m_deviceParams->getDevice()) {
|
||||||
@ -333,6 +422,11 @@ bool LimeSDRInput::start()
|
|||||||
|
|
||||||
if (m_running) { stop(); }
|
if (m_running) { stop(); }
|
||||||
|
|
||||||
|
if (!acquireChannel())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
applySettings(m_settings, true);
|
applySettings(m_settings, true);
|
||||||
|
|
||||||
// start / stop streaming is done in the thread.
|
// start / stop streaming is done in the thread.
|
||||||
@ -360,6 +454,8 @@ bool LimeSDRInput::start()
|
|||||||
|
|
||||||
void LimeSDRInput::stop()
|
void LimeSDRInput::stop()
|
||||||
{
|
{
|
||||||
|
qDebug("LimeSDRInput::stop");
|
||||||
|
|
||||||
if (m_limeSDRInputThread != 0)
|
if (m_limeSDRInputThread != 0)
|
||||||
{
|
{
|
||||||
m_limeSDRInputThread->stopWork();
|
m_limeSDRInputThread->stopWork();
|
||||||
@ -369,6 +465,8 @@ void LimeSDRInput::stop()
|
|||||||
|
|
||||||
m_deviceShared.m_thread = 0;
|
m_deviceShared.m_thread = 0;
|
||||||
m_running = false;
|
m_running = false;
|
||||||
|
|
||||||
|
releaseChannel();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString& LimeSDRInput::getDeviceDescription() const
|
const QString& LimeSDRInput::getDeviceDescription() const
|
||||||
@ -622,7 +720,7 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
|
|||||||
(m_settings.m_ncoFrequency != settings.m_ncoFrequency) ||
|
(m_settings.m_ncoFrequency != settings.m_ncoFrequency) ||
|
||||||
(m_settings.m_antennaPath != settings.m_antennaPath) || force)
|
(m_settings.m_antennaPath != settings.m_antennaPath) || force)
|
||||||
{
|
{
|
||||||
suspendOwnThread = true;
|
suspendOwnThread = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// suspend buddies threads or own thread
|
// suspend buddies threads or own thread
|
||||||
@ -679,7 +777,7 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
|
|||||||
{
|
{
|
||||||
m_settings.m_gain = settings.m_gain;
|
m_settings.m_gain = settings.m_gain;
|
||||||
|
|
||||||
if (m_deviceShared.m_deviceParams->getDevice() != 0)
|
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
|
||||||
{
|
{
|
||||||
if (LMS_SetGaindB(m_deviceShared.m_deviceParams->getDevice(),
|
if (LMS_SetGaindB(m_deviceShared.m_deviceParams->getDevice(),
|
||||||
LMS_CH_RX,
|
LMS_CH_RX,
|
||||||
@ -701,7 +799,7 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
|
|||||||
m_settings.m_tiaGain = settings.m_tiaGain;
|
m_settings.m_tiaGain = settings.m_tiaGain;
|
||||||
m_settings.m_pgaGain = settings.m_pgaGain;
|
m_settings.m_pgaGain = settings.m_pgaGain;
|
||||||
|
|
||||||
if (m_deviceShared.m_deviceParams->getDevice() != 0)
|
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
|
||||||
{
|
{
|
||||||
if (DeviceLimeSDR::SetRFELNA_dB(m_deviceShared.m_deviceParams->getDevice(),
|
if (DeviceLimeSDR::SetRFELNA_dB(m_deviceShared.m_deviceParams->getDevice(),
|
||||||
m_deviceShared.m_channel,
|
m_deviceShared.m_channel,
|
||||||
@ -743,7 +841,7 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
|
|||||||
{
|
{
|
||||||
m_settings.m_gain = settings.m_gain;
|
m_settings.m_gain = settings.m_gain;
|
||||||
|
|
||||||
if (m_deviceShared.m_deviceParams->getDevice() != 0)
|
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
|
||||||
{
|
{
|
||||||
if (LMS_SetGaindB(m_deviceShared.m_deviceParams->getDevice(),
|
if (LMS_SetGaindB(m_deviceShared.m_deviceParams->getDevice(),
|
||||||
LMS_CH_RX,
|
LMS_CH_RX,
|
||||||
@ -764,7 +862,7 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
|
|||||||
{
|
{
|
||||||
m_settings.m_lnaGain = settings.m_lnaGain;
|
m_settings.m_lnaGain = settings.m_lnaGain;
|
||||||
|
|
||||||
if (m_deviceShared.m_deviceParams->getDevice() != 0)
|
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
|
||||||
{
|
{
|
||||||
if (DeviceLimeSDR::SetRFELNA_dB(m_deviceShared.m_deviceParams->getDevice(),
|
if (DeviceLimeSDR::SetRFELNA_dB(m_deviceShared.m_deviceParams->getDevice(),
|
||||||
m_deviceShared.m_channel,
|
m_deviceShared.m_channel,
|
||||||
@ -783,7 +881,7 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
|
|||||||
{
|
{
|
||||||
m_settings.m_tiaGain = settings.m_tiaGain;
|
m_settings.m_tiaGain = settings.m_tiaGain;
|
||||||
|
|
||||||
if (m_deviceShared.m_deviceParams->getDevice() != 0)
|
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
|
||||||
{
|
{
|
||||||
if (DeviceLimeSDR::SetRFETIA_dB(m_deviceShared.m_deviceParams->getDevice(),
|
if (DeviceLimeSDR::SetRFETIA_dB(m_deviceShared.m_deviceParams->getDevice(),
|
||||||
m_deviceShared.m_channel,
|
m_deviceShared.m_channel,
|
||||||
@ -802,7 +900,7 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
|
|||||||
{
|
{
|
||||||
m_settings.m_pgaGain = settings.m_pgaGain;
|
m_settings.m_pgaGain = settings.m_pgaGain;
|
||||||
|
|
||||||
if (m_deviceShared.m_deviceParams->getDevice() != 0)
|
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
|
||||||
{
|
{
|
||||||
if (DeviceLimeSDR::SetRBBPGA_dB(m_deviceShared.m_deviceParams->getDevice(),
|
if (DeviceLimeSDR::SetRBBPGA_dB(m_deviceShared.m_deviceParams->getDevice(),
|
||||||
m_deviceShared.m_channel,
|
m_deviceShared.m_channel,
|
||||||
@ -825,7 +923,7 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
|
|||||||
m_settings.m_devSampleRate = settings.m_devSampleRate;
|
m_settings.m_devSampleRate = settings.m_devSampleRate;
|
||||||
m_settings.m_log2HardDecim = settings.m_log2HardDecim;
|
m_settings.m_log2HardDecim = settings.m_log2HardDecim;
|
||||||
|
|
||||||
if (m_deviceShared.m_deviceParams->getDevice() != 0)
|
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
|
||||||
{
|
{
|
||||||
if (LMS_SetSampleRateDir(m_deviceShared.m_deviceParams->getDevice(),
|
if (LMS_SetSampleRateDir(m_deviceShared.m_deviceParams->getDevice(),
|
||||||
LMS_CH_RX,
|
LMS_CH_RX,
|
||||||
@ -853,7 +951,7 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
|
|||||||
{
|
{
|
||||||
m_settings.m_lpfBW = settings.m_lpfBW;
|
m_settings.m_lpfBW = settings.m_lpfBW;
|
||||||
|
|
||||||
if (m_deviceShared.m_deviceParams->getDevice() != 0)
|
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
|
||||||
{
|
{
|
||||||
if (LMS_SetLPFBW(m_deviceShared.m_deviceParams->getDevice(),
|
if (LMS_SetLPFBW(m_deviceShared.m_deviceParams->getDevice(),
|
||||||
LMS_CH_RX,
|
LMS_CH_RX,
|
||||||
@ -876,7 +974,7 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
|
|||||||
m_settings.m_lpfFIRBW = settings.m_lpfFIRBW;
|
m_settings.m_lpfFIRBW = settings.m_lpfFIRBW;
|
||||||
m_settings.m_lpfFIREnable = settings.m_lpfFIREnable;
|
m_settings.m_lpfFIREnable = settings.m_lpfFIREnable;
|
||||||
|
|
||||||
if (m_deviceShared.m_deviceParams->getDevice() != 0)
|
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
|
||||||
{
|
{
|
||||||
if (LMS_SetGFIRLPF(m_deviceShared.m_deviceParams->getDevice(),
|
if (LMS_SetGFIRLPF(m_deviceShared.m_deviceParams->getDevice(),
|
||||||
LMS_CH_RX,
|
LMS_CH_RX,
|
||||||
@ -904,7 +1002,7 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
|
|||||||
m_settings.m_ncoFrequency = settings.m_ncoFrequency;
|
m_settings.m_ncoFrequency = settings.m_ncoFrequency;
|
||||||
m_settings.m_ncoEnable = settings.m_ncoEnable;
|
m_settings.m_ncoEnable = settings.m_ncoEnable;
|
||||||
|
|
||||||
if (m_deviceShared.m_deviceParams->getDevice() != 0)
|
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
|
||||||
{
|
{
|
||||||
if (DeviceLimeSDR::setNCOFrequency(m_deviceShared.m_deviceParams->getDevice(),
|
if (DeviceLimeSDR::setNCOFrequency(m_deviceShared.m_deviceParams->getDevice(),
|
||||||
LMS_CH_RX,
|
LMS_CH_RX,
|
||||||
@ -945,7 +1043,7 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
|
|||||||
{
|
{
|
||||||
m_settings.m_antennaPath = settings.m_antennaPath;
|
m_settings.m_antennaPath = settings.m_antennaPath;
|
||||||
|
|
||||||
if (m_deviceShared.m_deviceParams->getDevice() != 0)
|
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
|
||||||
{
|
{
|
||||||
if (DeviceLimeSDR::setRxAntennaPath(m_deviceShared.m_deviceParams->getDevice(),
|
if (DeviceLimeSDR::setRxAntennaPath(m_deviceShared.m_deviceParams->getDevice(),
|
||||||
m_deviceShared.m_channel,
|
m_deviceShared.m_channel,
|
||||||
@ -969,7 +1067,7 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
|
|||||||
m_settings.m_centerFrequency = settings.m_centerFrequency;
|
m_settings.m_centerFrequency = settings.m_centerFrequency;
|
||||||
forwardChangeRxDSP = true;
|
forwardChangeRxDSP = true;
|
||||||
|
|
||||||
if (m_deviceShared.m_deviceParams->getDevice() != 0)
|
if (m_deviceShared.m_deviceParams->getDevice() != 0 && m_channelAcquired)
|
||||||
{
|
{
|
||||||
if (LMS_SetLOFrequency(m_deviceShared.m_deviceParams->getDevice(),
|
if (LMS_SetLOFrequency(m_deviceShared.m_deviceParams->getDevice(),
|
||||||
LMS_CH_RX,
|
LMS_CH_RX,
|
||||||
|
@ -212,11 +212,14 @@ private:
|
|||||||
QString m_deviceDescription;
|
QString m_deviceDescription;
|
||||||
bool m_running;
|
bool m_running;
|
||||||
DeviceLimeSDRShared m_deviceShared;
|
DeviceLimeSDRShared m_deviceShared;
|
||||||
|
bool m_channelAcquired;
|
||||||
lms_stream_t m_streamId;
|
lms_stream_t m_streamId;
|
||||||
FileRecord *m_fileSink; //!< File sink to record device I/Q output
|
FileRecord *m_fileSink; //!< File sink to record device I/Q output
|
||||||
|
|
||||||
bool openDevice();
|
bool openDevice();
|
||||||
void closeDevice();
|
void closeDevice();
|
||||||
|
bool acquireChannel();
|
||||||
|
void releaseChannel();
|
||||||
void suspendRxBuddies();
|
void suspendRxBuddies();
|
||||||
void resumeRxBuddies();
|
void resumeRxBuddies();
|
||||||
void suspendTxBuddies();
|
void suspendTxBuddies();
|
||||||
|
Loading…
Reference in New Issue
Block a user