mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-11-03 13:11:20 -05:00 
			
		
		
		
	PlutoSDR: added common parameters and shared structure
This commit is contained in:
		
							parent
							
								
									8ab3ad3b63
								
							
						
					
					
						commit
						6fa8b4ac87
					
				@ -6,12 +6,16 @@ set(plutosdrdevice_SOURCES
 | 
				
			|||||||
    deviceplutosdr.cpp
 | 
					    deviceplutosdr.cpp
 | 
				
			||||||
    deviceplutosdrbox.cpp
 | 
					    deviceplutosdrbox.cpp
 | 
				
			||||||
    deviceplutosdrscan.cpp
 | 
					    deviceplutosdrscan.cpp
 | 
				
			||||||
 | 
					    deviceplutosdrparams.cpp
 | 
				
			||||||
 | 
					    deviceplutosdrshared.cpp
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set(plutosdrdevice_HEADERS
 | 
					set(plutosdrdevice_HEADERS
 | 
				
			||||||
    deviceplutosdr.h
 | 
					    deviceplutosdr.h
 | 
				
			||||||
    deviceplutsdrobox.h
 | 
					    deviceplutsdrobox.h
 | 
				
			||||||
    deviceplutosdrscan.h
 | 
					    deviceplutosdrscan.h
 | 
				
			||||||
 | 
					    deviceplutosdrparams.h
 | 
				
			||||||
 | 
					    deviceplutosdrshared.h
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if (BUILD_DEBIAN)
 | 
					if (BUILD_DEBIAN)
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										40
									
								
								devices/plutosdr/deviceplutosdrparams.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								devices/plutosdr/deviceplutosdrparams.cpp
									
									
									
									
									
										Normal 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;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										47
									
								
								devices/plutosdr/deviceplutosdrparams.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								devices/plutosdr/deviceplutosdrparams.h
									
									
									
									
									
										Normal 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_ */
 | 
				
			||||||
							
								
								
									
										20
									
								
								devices/plutosdr/deviceplutosdrshared.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								devices/plutosdr/deviceplutosdrshared.cpp
									
									
									
									
									
										Normal 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
 | 
				
			||||||
							
								
								
									
										56
									
								
								devices/plutosdr/deviceplutosdrshared.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								devices/plutosdr/deviceplutosdrshared.h
									
									
									
									
									
										Normal 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_ */
 | 
				
			||||||
@ -87,3 +87,23 @@ bool PlutoSDRInput::handleMessage(const Message& message)
 | 
				
			|||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool PlutoSDRInput::openDevice()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void PlutoSDRInput::closeDevice()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void PlutoSDRInput::suspendBuddies()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void PlutoSDRInput::resumeBuddies()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -67,8 +67,12 @@ public:
 | 
				
			|||||||
    QString m_deviceDescription;
 | 
					    QString m_deviceDescription;
 | 
				
			||||||
    PlutoSDRInputSettings m_settings;
 | 
					    PlutoSDRInputSettings m_settings;
 | 
				
			||||||
    bool m_running;
 | 
					    bool m_running;
 | 
				
			||||||
 | 
					 | 
				
			||||||
    QMutex m_mutex;
 | 
					    QMutex m_mutex;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    bool openDevice();
 | 
				
			||||||
 | 
					    void closeDevice();
 | 
				
			||||||
 | 
					    void suspendBuddies();
 | 
				
			||||||
 | 
					    void resumeBuddies();
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user