diff --git a/plugins/samplesource/plutosdrinput/plutosdrinput.cpp b/plugins/samplesource/plutosdrinput/plutosdrinput.cpp index 2e0b8a627..66b722f85 100644 --- a/plugins/samplesource/plutosdrinput/plutosdrinput.cpp +++ b/plugins/samplesource/plutosdrinput/plutosdrinput.cpp @@ -19,6 +19,8 @@ #include "dsp/filerecord.h" #include "device/devicesourceapi.h" #include "device/devicesinkapi.h" +#include "plutosdr/deviceplutosdrparams.h" +#include "plutosdr/deviceplutosdrbox.h" #include "plutosdrinput.h" @@ -90,7 +92,53 @@ bool PlutoSDRInput::handleMessage(const Message& message) bool PlutoSDRInput::openDevice() { + if (!m_sampleFifo.setSize(96000 * 4)) + { + qCritical("PlutoSDRInput::openDevice: could not allocate SampleFifo"); + return false; + } + else + { + qDebug("PlutoSDRInput::openDevice: allocated SampleFifo"); + } + // look for Tx buddy and get reference to common parameters + if (m_deviceAPI->getSinkBuddies().size() > 0) // then sink + { + qDebug("PlutoSDRInput::openDevice: look at Tx buddy"); + + DeviceSinkAPI *sinkBuddy = m_deviceAPI->getSinkBuddies()[0]; + m_deviceShared = *((DevicePlutoSDRShared *) sinkBuddy->getBuddySharedPtr()); // copy parameters + + if (m_deviceShared.m_deviceParams == 0) + { + qCritical("PlutoSDRInput::openDevice: cannot get device parameters from Tx buddy"); + return false; // the device params should have been created by the buddy + } + else + { + qDebug("PlutoSDRInput::openDevice: getting device parameters from Tx buddy"); + } + } + // There is no buddy then create the first PlutoSDR common parameters + // open the device this will also populate common fields + else + { + qDebug("PlutoSDRInput::openDevice: open device here"); + + m_deviceShared.m_deviceParams = new DevicePlutoSDRParams(); + char serial[256]; + strcpy(serial, qPrintable(m_deviceAPI->getSampleSourceSerial())); + m_deviceShared.m_deviceParams->open(serial); + } + + m_deviceAPI->setBuddySharedPtr(&m_deviceShared); // propagate common parameters to API + + // acquire the channel + DevicePlutoSDRBox *plutoBox = m_deviceShared.m_deviceParams->getBox(); + plutoBox->openRx(); + + // TODO: get Rx buffer } void PlutoSDRInput::closeDevice() diff --git a/plugins/samplesource/plutosdrinput/plutosdrinput.h b/plugins/samplesource/plutosdrinput/plutosdrinput.h index 4b1672219..f3154dfe8 100644 --- a/plugins/samplesource/plutosdrinput/plutosdrinput.h +++ b/plugins/samplesource/plutosdrinput/plutosdrinput.h @@ -21,7 +21,7 @@ #include #include "util/message.h" - +#include "plutosdr/deviceplutosdrshared.h" #include "plutosdrinputsettings.h" class DeviceSourceAPI; @@ -67,6 +67,7 @@ public: QString m_deviceDescription; PlutoSDRInputSettings m_settings; bool m_running; + DevicePlutoSDRShared m_deviceShared; QMutex m_mutex; bool openDevice();