1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-27 02:09:14 -05:00

LimeSDR input: open, close, suspend, resume

This commit is contained in:
f4exb 2017-09-06 00:57:27 +02:00
parent ed47cc4d2e
commit 4322a732be
2 changed files with 35 additions and 3 deletions

View File

@ -30,7 +30,8 @@ PlutoSDRInput::PlutoSDRInput(DeviceSourceAPI *deviceAPI) :
m_deviceAPI(deviceAPI), m_deviceAPI(deviceAPI),
m_fileSink(0), m_fileSink(0),
m_deviceDescription("PlutoSDR"), m_deviceDescription("PlutoSDR"),
m_running(false) m_running(false),
m_plutoRxBuffer(0)
{ {
char recFileNameCStr[30]; char recFileNameCStr[30];
sprintf(recFileNameCStr, "test_%d.sdriq", m_deviceAPI->getDeviceUID()); sprintf(recFileNameCStr, "test_%d.sdriq", m_deviceAPI->getDeviceUID());
@ -137,21 +138,50 @@ bool PlutoSDRInput::openDevice()
// acquire the channel // acquire the channel
DevicePlutoSDRBox *plutoBox = m_deviceShared.m_deviceParams->getBox(); DevicePlutoSDRBox *plutoBox = m_deviceShared.m_deviceParams->getBox();
plutoBox->openRx(); plutoBox->openRx();
m_plutoRxBuffer = plutoBox->createRxBuffer(1024*1024, false);
// TODO: get Rx buffer
} }
void PlutoSDRInput::closeDevice() void PlutoSDRInput::closeDevice()
{ {
if (m_deviceShared.m_deviceParams->getBox() == 0) { // was never open
return;
}
if (m_deviceAPI->getSinkBuddies().size() == 0)
{
m_deviceShared.m_deviceParams->close();
delete m_deviceShared.m_deviceParams;
m_deviceShared.m_deviceParams = 0;
}
} }
void PlutoSDRInput::suspendBuddies() void PlutoSDRInput::suspendBuddies()
{ {
// suspend Tx buddy's thread
for (unsigned int i = 0; i < m_deviceAPI->getSinkBuddies().size(); i++)
{
DeviceSinkAPI *buddy = m_deviceAPI->getSinkBuddies()[i];
DevicePlutoSDRShared *buddyShared = (DevicePlutoSDRShared *) buddy->getBuddySharedPtr();
if (buddyShared->m_thread) {
buddyShared->m_thread->stopWork();
}
}
} }
void PlutoSDRInput::resumeBuddies() void PlutoSDRInput::resumeBuddies()
{ {
// resume Tx buddy's thread
for (unsigned int i = 0; i < m_deviceAPI->getSinkBuddies().size(); i++)
{
DeviceSinkAPI *buddy = m_deviceAPI->getSinkBuddies()[i];
DevicePlutoSDRShared *buddyShared = (DevicePlutoSDRShared *) buddy->getBuddySharedPtr();
if (buddyShared->m_thread) {
buddyShared->m_thread->startWork();
}
}
} }

View File

@ -19,6 +19,7 @@
#include <QString> #include <QString>
#include "iio.h"
#include <dsp/devicesamplesource.h> #include <dsp/devicesamplesource.h>
#include "util/message.h" #include "util/message.h"
#include "plutosdr/deviceplutosdrshared.h" #include "plutosdr/deviceplutosdrshared.h"
@ -68,6 +69,7 @@ public:
PlutoSDRInputSettings m_settings; PlutoSDRInputSettings m_settings;
bool m_running; bool m_running;
DevicePlutoSDRShared m_deviceShared; DevicePlutoSDRShared m_deviceShared;
struct iio_buffer *m_plutoRxBuffer;
QMutex m_mutex; QMutex m_mutex;
bool openDevice(); bool openDevice();