PlutoSDR: added common parameters and shared structure

This commit is contained in:
f4exb 2017-09-05 16:23:10 +02:00
parent 8ab3ad3b63
commit 6fa8b4ac87
7 changed files with 192 additions and 1 deletions

View File

@ -6,12 +6,16 @@ set(plutosdrdevice_SOURCES
deviceplutosdr.cpp
deviceplutosdrbox.cpp
deviceplutosdrscan.cpp
deviceplutosdrparams.cpp
deviceplutosdrshared.cpp
)
set(plutosdrdevice_HEADERS
deviceplutosdr.h
deviceplutsdrobox.h
deviceplutosdrscan.h
deviceplutosdrparams.h
deviceplutosdrshared.h
)
if (BUILD_DEBIAN)

View File

@ -0,0 +1,40 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "deviceplutosdrparams.h"
#include "deviceplutosdr.h"
DevicePlutoSDRParams::DevicePlutoSDRParams() :
m_box(0)
{
}
DevicePlutoSDRParams::~DevicePlutoSDRParams()
{
}
bool DevicePlutoSDRParams::open(const std::string& serial)
{
m_box = DevicePlutoSDR::getDeviceFromSerial(serial);
return m_box != 0;
}
void DevicePlutoSDRParams::close()
{
delete m_box;
m_box = 0;
}

View File

@ -0,0 +1,47 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef DEVICES_PLUTOSDR_DEVICEPLUTOSDRPARAMS_H_
#define DEVICES_PLUTOSDR_DEVICEPLUTOSDRPARAMS_H_
#include <string>
class DevicePlutoSDRBox;
/**
* This structure refers to one physical device shared among parties (logical devices represented by
* the DeviceSinkAPI or DeviceSourceAPI).
* It allows storing information on the common resources in one place and is shared among participants.
* There is only one copy that is constructed by the first participant and destroyed by the last.
* A participant knows it is the first or last by checking the lists of buddies (Rx + Tx).
*/
struct DevicePlutoSDRParams
{
public:
DevicePlutoSDRParams();
~DevicePlutoSDRParams();
bool open(const std::string& serial);
void close();
DevicePlutoSDRBox *getBox() { return m_box; }
private:
DevicePlutoSDRBox *m_box;
};
#endif /* DEVICES_PLUTOSDR_DEVICEPLUTOSDRPARAMS_H_ */

View File

@ -0,0 +1,20 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "deviceplutosdrshared.h"
const float DevicePlutoSDRShared::m_sampleFifoLengthInSeconds = 0.25;
const int DevicePlutoSDRShared::m_sampleFifoMinSize = 48000; // 192kS/s knee

View File

@ -0,0 +1,56 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef DEVICES_PLUTOSDR_DEVICEPLUTOSDRSHARED_H_
#define DEVICES_PLUTOSDR_DEVICEPLUTOSDRSHARED_H_
/**
* Structure shared by a buddy with other buddies
*/
class DevicePlutoSDRShared
{
public:
/**
* Expose own samples processing thread control
*/
class ThreadInterface
{
public:
virtual void startWork() = 0;
virtual void stopWork() = 0;
virtual void setDeviceSampleRate(int sampleRate) = 0;
virtual bool isRunning() = 0;
};
DevicePlutoSDRParams *m_deviceParams; //!< unique hardware device parameters
ThreadInterface *m_thread; //!< holds the thread address if started else 0
bool m_threadWasRunning; //!< flag to know if thread needs to be resumed after suspend
static const float m_sampleFifoLengthInSeconds;
static const int m_sampleFifoMinSize;
DevicePlutoSDRShared() :
m_deviceParams(0),
m_thread(0),
m_threadWasRunning(false)
{}
~DevicePlutoSDRShared()
{}
};
#endif /* DEVICES_PLUTOSDR_DEVICEPLUTOSDRSHARED_H_ */

View File

@ -87,3 +87,23 @@ bool PlutoSDRInput::handleMessage(const Message& message)
return false;
}
}
bool PlutoSDRInput::openDevice()
{
}
void PlutoSDRInput::closeDevice()
{
}
void PlutoSDRInput::suspendBuddies()
{
}
void PlutoSDRInput::resumeBuddies()
{
}

View File

@ -67,8 +67,12 @@ public:
QString m_deviceDescription;
PlutoSDRInputSettings m_settings;
bool m_running;
QMutex m_mutex;
bool openDevice();
void closeDevice();
void suspendBuddies();
void resumeBuddies();
};