| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // 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 <QMutexLocker>
 | 
					
						
							|  |  |  | #include <QDebug>
 | 
					
						
							|  |  |  | #include <cstddef>
 | 
					
						
							|  |  |  | #include <string.h>
 | 
					
						
							|  |  |  | #include "lime/LimeSuite.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "device/devicesourceapi.h"
 | 
					
						
							|  |  |  | #include "device/devicesinkapi.h"
 | 
					
						
							|  |  |  | #include "dsp/dspcommands.h"
 | 
					
						
							|  |  |  | #include "limesdrinput.h"
 | 
					
						
							|  |  |  | #include "limesdrinputthread.h"
 | 
					
						
							|  |  |  | #include "limesdr/devicelimesdrparam.h"
 | 
					
						
							| 
									
										
										
										
											2017-04-23 03:36:10 +02:00
										 |  |  | #include "limesdr/devicelimesdrshared.h"
 | 
					
						
							| 
									
										
										
										
											2017-04-20 18:21:01 +02:00
										 |  |  | #include "limesdr/devicelimesdr.h"
 | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgConfigureLimeSDR, Message) | 
					
						
							| 
									
										
										
										
											2017-04-19 18:41:55 +02:00
										 |  |  | MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgGetStreamInfo, Message) | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  | MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgSetReferenceConfig, Message) | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgReportLimeSDRToGUI, Message) | 
					
						
							| 
									
										
										
										
											2017-04-19 18:41:55 +02:00
										 |  |  | MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgReportStreamInfo, Message) | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | LimeSDRInput::LimeSDRInput(DeviceSourceAPI *deviceAPI) : | 
					
						
							|  |  |  |     m_deviceAPI(deviceAPI), | 
					
						
							|  |  |  |     m_settings(), | 
					
						
							|  |  |  |     m_limeSDRInputThread(0), | 
					
						
							|  |  |  |     m_deviceDescription(), | 
					
						
							|  |  |  |     m_running(false), | 
					
						
							|  |  |  |     m_firstConfig(true) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-04-20 23:32:08 +02:00
										 |  |  |     m_streamId.handle = 0; | 
					
						
							| 
									
										
										
										
											2017-04-23 04:01:00 +02:00
										 |  |  |     suspendBuddies(); | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |     openDevice(); | 
					
						
							| 
									
										
										
										
											2017-04-23 04:01:00 +02:00
										 |  |  |     resumeBuddies(); | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | LimeSDRInput::~LimeSDRInput() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_running) stop(); | 
					
						
							| 
									
										
										
										
											2017-04-23 04:01:00 +02:00
										 |  |  |     suspendBuddies(); | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |     closeDevice(); | 
					
						
							| 
									
										
										
										
											2017-04-23 04:01:00 +02:00
										 |  |  |     resumeBuddies(); | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool LimeSDRInput::openDevice() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-04-18 22:22:21 +02:00
										 |  |  |     if (!m_sampleFifo.setSize(96000 * 4)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         qCritical("LimeSDRInput::openDevice: could not allocate SampleFifo"); | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         qDebug("LimeSDRInput::openDevice: allocated SampleFifo"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |     // look for Rx buddies and get reference to common parameters
 | 
					
						
							|  |  |  |     // if there is a channel left take the first available
 | 
					
						
							|  |  |  |     if (m_deviceAPI->getSourceBuddies().size() > 0) // look source sibling first
 | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-04-19 01:04:57 +02:00
										 |  |  |         qDebug("LimeSDRInput::openDevice: look in Rx buddies"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |         DeviceSourceAPI *sourceBuddy = m_deviceAPI->getSourceBuddies()[0]; | 
					
						
							|  |  |  |         m_deviceShared = *((DeviceLimeSDRShared *) sourceBuddy->getBuddySharedPtr()); // copy shared data
 | 
					
						
							|  |  |  |         DeviceLimeSDRParams *deviceParams = m_deviceShared.m_deviceParams; // get device parameters
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (deviceParams == 0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             qCritical("LimeSDRInput::openDevice: cannot get device parameters from Rx buddy"); | 
					
						
							|  |  |  |             return false; // the device params should have been created by the buddy
 | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-19 01:04:57 +02:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             qDebug("LimeSDRInput::openDevice: getting device parameters from Rx buddy"); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if (m_deviceAPI->getSourceBuddies().size() == deviceParams->m_nbRxChannels) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2017-04-19 01:04:57 +02:00
										 |  |  |             qCritical("LimeSDRInput::openDevice: no more Rx channels available in device"); | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |             return false; // no more Rx channels available in device
 | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-19 01:04:57 +02:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             qDebug("LimeSDRInput::openDevice: at least one more Rx channel is available in device"); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |         // look for unused channel number
 | 
					
						
							|  |  |  |         char *busyChannels = new char[deviceParams->m_nbRxChannels]; | 
					
						
							|  |  |  |         memset(busyChannels, 0, deviceParams->m_nbRxChannels); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for (int i = 0; i < m_deviceAPI->getSourceBuddies().size(); i++) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             DeviceSourceAPI *buddy = m_deviceAPI->getSourceBuddies()[i]; | 
					
						
							|  |  |  |             DeviceLimeSDRShared *buddyShared = (DeviceLimeSDRShared *) buddy->getBuddySharedPtr(); | 
					
						
							|  |  |  |             busyChannels[buddyShared->m_channel] = 1; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         std::size_t ch = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for (;ch < deviceParams->m_nbRxChannels; ch++) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             if (busyChannels[ch] == 0) { | 
					
						
							|  |  |  |                 break; // first available is the good one
 | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         m_deviceShared.m_channel = ch; | 
					
						
							|  |  |  |         delete[] busyChannels; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     // look for Tx buddies and get reference to common parameters
 | 
					
						
							|  |  |  |     // take the first Rx channel
 | 
					
						
							|  |  |  |     else if (m_deviceAPI->getSinkBuddies().size() > 0) // then sink
 | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-04-19 01:04:57 +02:00
										 |  |  |         qDebug("LimeSDRInput::openDevice: look in Tx buddies"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |         DeviceSinkAPI *sinkBuddy = m_deviceAPI->getSinkBuddies()[0]; | 
					
						
							|  |  |  |         m_deviceShared = *((DeviceLimeSDRShared *) sinkBuddy->getBuddySharedPtr()); // copy parameters
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (m_deviceShared.m_deviceParams == 0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             qCritical("LimeSDRInput::openDevice: cannot get device parameters from Tx buddy"); | 
					
						
							|  |  |  |             return false; // the device params should have been created by the buddy
 | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-19 01:04:57 +02:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             qDebug("LimeSDRInput::openDevice: getting device parameters from Tx buddy"); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         m_deviceShared.m_channel = 0; // take first channel
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     // There are no buddies then create the first LimeSDR common parameters
 | 
					
						
							|  |  |  |     // open the device this will also populate common fields
 | 
					
						
							|  |  |  |     // take the first Rx channel
 | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-04-19 01:04:57 +02:00
										 |  |  |         qDebug("LimeSDRInput::openDevice: open device here"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |         m_deviceShared.m_deviceParams = new DeviceLimeSDRParams(); | 
					
						
							|  |  |  |         char serial[256]; | 
					
						
							|  |  |  |         strcpy(serial, qPrintable(m_deviceAPI->getSampleSourceSerial())); | 
					
						
							|  |  |  |         m_deviceShared.m_deviceParams->open(serial); | 
					
						
							|  |  |  |         m_deviceShared.m_channel = 0; // take first channel
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_deviceAPI->setBuddySharedPtr(&m_deviceShared); // propagate common parameters to API
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // acquire the channel
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (LMS_EnableChannel(m_deviceShared.m_deviceParams->getDevice(), LMS_CH_RX, m_deviceShared.m_channel, true) != 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         qCritical("LimeSDRInput::openDevice: cannot enable Rx channel %lu", m_deviceShared.m_channel); | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-04-19 01:04:57 +02:00
										 |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         qDebug("LimeSDRInput::openDevice: Rx channel %lu enabled", m_deviceShared.m_channel); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-19 08:19:09 +02:00
										 |  |  |     // set up the stream
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_streamId.channel =  m_deviceShared.m_channel; //channel number
 | 
					
						
							| 
									
										
										
										
											2017-04-24 09:57:21 +02:00
										 |  |  |     m_streamId.fifoSize = 1024 * 1024;              //fifo size in samples
 | 
					
						
							| 
									
										
										
										
											2017-04-19 08:19:09 +02:00
										 |  |  |     m_streamId.throughputVsLatency = 1.0;           //optimize for max throughput
 | 
					
						
							|  |  |  |     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::start: cannot setup the stream on Rx channel %lu", m_deviceShared.m_channel); | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         qDebug("LimeSDRInput::start: stream set up on Rx channel %lu", m_deviceShared.m_channel); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-23 04:01:00 +02:00
										 |  |  |     return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInput::suspendBuddies() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // suspend Rx buddy's threads
 | 
					
						
							| 
									
										
										
										
											2017-04-20 01:39:05 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     for (int i = 0; i < m_deviceAPI->getSourceBuddies().size(); i++) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceSourceAPI *buddy = m_deviceAPI->getSourceBuddies()[i]; | 
					
						
							|  |  |  |         DeviceLimeSDRShared *buddyShared = (DeviceLimeSDRShared *) buddy->getBuddySharedPtr(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (buddyShared->m_thread) { | 
					
						
							| 
									
										
										
										
											2017-04-23 04:01:00 +02:00
										 |  |  |             buddyShared->m_thread->stopWork(); | 
					
						
							| 
									
										
										
										
											2017-04-20 01:39:05 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-23 04:01:00 +02:00
										 |  |  |     // suspend Tx buddy's threads
 | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-23 04:01:00 +02:00
										 |  |  |     for (int i = 0; i < m_deviceAPI->getSinkBuddies().size(); i++) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceSinkAPI *buddy = m_deviceAPI->getSinkBuddies()[i]; | 
					
						
							|  |  |  |         DeviceLimeSDRShared *buddyShared = (DeviceLimeSDRShared *) buddy->getBuddySharedPtr(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (buddyShared->m_thread) { | 
					
						
							|  |  |  |             buddyShared->m_thread->stopWork(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-04-23 04:01:00 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-23 04:01:00 +02:00
										 |  |  | void LimeSDRInput::resumeBuddies() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // resume Rx buddy's threads
 | 
					
						
							| 
									
										
										
										
											2017-04-20 01:39:05 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     for (int i = 0; i < m_deviceAPI->getSourceBuddies().size(); i++) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceSourceAPI *buddy = m_deviceAPI->getSourceBuddies()[i]; | 
					
						
							|  |  |  |         DeviceLimeSDRShared *buddyShared = (DeviceLimeSDRShared *) buddy->getBuddySharedPtr(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (buddyShared->m_thread) { | 
					
						
							| 
									
										
										
										
											2017-04-23 04:01:00 +02:00
										 |  |  |             buddyShared->m_thread->startWork(); | 
					
						
							| 
									
										
										
										
											2017-04-20 01:39:05 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-23 04:01:00 +02:00
										 |  |  |     // resume Tx buddy's threads
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (int i = 0; i < m_deviceAPI->getSinkBuddies().size(); i++) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceSinkAPI *buddy = m_deviceAPI->getSinkBuddies()[i]; | 
					
						
							|  |  |  |         DeviceLimeSDRShared *buddyShared = (DeviceLimeSDRShared *) buddy->getBuddySharedPtr(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (buddyShared->m_thread) { | 
					
						
							|  |  |  |             buddyShared->m_thread->startWork(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInput::closeDevice() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_deviceShared.m_deviceParams->getDevice() == 0) { // was never open
 | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-19 08:19:09 +02:00
										 |  |  |     // destroy the stream
 | 
					
						
							|  |  |  |     LMS_DestroyStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId); | 
					
						
							| 
									
										
										
										
											2017-04-20 23:32:08 +02:00
										 |  |  |     m_streamId.handle = 0; | 
					
						
							| 
									
										
										
										
											2017-04-19 08:19:09 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |     // release the channel
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (LMS_EnableChannel(m_deviceShared.m_deviceParams->getDevice(), LMS_CH_RX, m_deviceShared.m_channel, false) != 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         qWarning("LimeSDRInput::closeDevice: cannot disable Rx channel %lu", m_deviceShared.m_channel); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_deviceShared.m_channel = -1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // No buddies so effectively close the device
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ((m_deviceAPI->getSinkBuddies().size() == 0) && (m_deviceAPI->getSourceBuddies().size() == 0)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_deviceShared.m_deviceParams->close(); | 
					
						
							|  |  |  |         delete m_deviceShared.m_deviceParams; | 
					
						
							|  |  |  |         m_deviceShared.m_deviceParams = 0; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool LimeSDRInput::start() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (!m_deviceShared.m_deviceParams->getDevice()) { | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (m_running) stop(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-13 14:35:12 +02:00
										 |  |  |     applySettings(m_settings, true); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |     // start / stop streaming is done in the thread.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ((m_limeSDRInputThread = new LimeSDRInputThread(&m_streamId, &m_sampleFifo)) == 0) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-04-18 08:35:25 +02:00
										 |  |  |         qFatal("LimeSDRInput::start: cannot create thread"); | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |         stop(); | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-04-18 08:35:25 +02:00
										 |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         qDebug("LimeSDRInput::start: thread created"); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     m_limeSDRInputThread->setLog2Decimation(m_settings.m_log2SoftDecim); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_limeSDRInputThread->startWork(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-22 10:40:57 +02:00
										 |  |  |     m_deviceShared.m_thread = m_limeSDRInputThread; | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |     m_running = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInput::stop() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_limeSDRInputThread != 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_limeSDRInputThread->stopWork(); | 
					
						
							|  |  |  |         delete m_limeSDRInputThread; | 
					
						
							|  |  |  |         m_limeSDRInputThread = 0; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-20 00:01:11 +02:00
										 |  |  |     m_deviceShared.m_thread = 0; | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |     m_running = false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const QString& LimeSDRInput::getDeviceDescription() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_deviceDescription; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int LimeSDRInput::getSampleRate() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int rate = m_settings.m_devSampleRate; | 
					
						
							| 
									
										
										
										
											2017-04-19 00:00:47 +02:00
										 |  |  |     return (rate / (1<<m_settings.m_log2SoftDecim)); | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | quint64 LimeSDRInput::getCenterFrequency() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_settings.m_centerFrequency; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | std::size_t LimeSDRInput::getChannelIndex() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_deviceShared.m_channel; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInput::getLORange(float& minF, float& maxF, float& stepF) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     lms_range_t range = m_deviceShared.m_deviceParams->m_loRangeRx; | 
					
						
							|  |  |  |     minF = range.min; | 
					
						
							|  |  |  |     maxF = range.max; | 
					
						
							|  |  |  |     stepF = range.step; | 
					
						
							|  |  |  |     qDebug("LimeSDRInput::getLORange: min: %f max: %f step: %f", range.min, range.max, range.step); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInput::getSRRange(float& minF, float& maxF, float& stepF) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     lms_range_t range = m_deviceShared.m_deviceParams->m_srRangeRx; | 
					
						
							|  |  |  |     minF = range.min; | 
					
						
							|  |  |  |     maxF = range.max; | 
					
						
							|  |  |  |     stepF = range.step; | 
					
						
							|  |  |  |     qDebug("LimeSDRInput::getSRRange: min: %f max: %f step: %f", range.min, range.max, range.step); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInput::getLPRange(float& minF, float& maxF, float& stepF) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     lms_range_t range = m_deviceShared.m_deviceParams->m_lpfRangeRx; | 
					
						
							|  |  |  |     minF = range.min; | 
					
						
							|  |  |  |     maxF = range.max; | 
					
						
							|  |  |  |     stepF = range.step; | 
					
						
							|  |  |  |     qDebug("LimeSDRInput::getLPRange: min: %f max: %f step: %f", range.min, range.max, range.step); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | uint32_t LimeSDRInput::getHWLog2Decim() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_deviceShared.m_deviceParams->m_log2OvSRRx; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool LimeSDRInput::handleMessage(const Message& message) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (MsgConfigureLimeSDR::match(message)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         MsgConfigureLimeSDR& conf = (MsgConfigureLimeSDR&) message; | 
					
						
							|  |  |  |         qDebug() << "LimeSDRInput::handleMessage: MsgConfigureLimeSDR"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (!applySettings(conf.getSettings(), m_firstConfig)) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             qDebug("LimeSDRInput::handleMessage config error"); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             m_firstConfig = false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (MsgSetReferenceConfig::match(message)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         MsgSetReferenceConfig& conf = (MsgSetReferenceConfig&) message; | 
					
						
							| 
									
										
										
										
											2017-04-19 01:04:57 +02:00
										 |  |  |         qDebug() << "LimeSDRInput::handleMessage: MsgSetReferenceConfig"; | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |         m_settings = conf.getSettings(); | 
					
						
							| 
									
										
										
										
											2017-04-21 00:14:55 +02:00
										 |  |  |         m_deviceShared.m_ncoFrequency = m_settings.m_ncoEnable ? m_settings.m_ncoFrequency : 0; // for buddies
 | 
					
						
							|  |  |  |         m_deviceShared.m_centerFrequency = m_settings.m_centerFrequency; // for buddies
 | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-04-19 18:41:55 +02:00
										 |  |  |     else if (MsgGetStreamInfo::match(message)) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-04-20 00:48:00 +02:00
										 |  |  | //        qDebug() << "LimeSDRInput::handleMessage: MsgGetStreamInfo";
 | 
					
						
							| 
									
										
										
										
											2017-04-19 18:41:55 +02:00
										 |  |  |         lms_stream_status_t status; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-21 00:14:55 +02:00
										 |  |  |         if (m_streamId.handle && (LMS_GetStreamStatus(&m_streamId, &status) == 0)) | 
					
						
							| 
									
										
										
										
											2017-04-19 18:41:55 +02:00
										 |  |  |         { | 
					
						
							|  |  |  |             MsgReportStreamInfo *report = MsgReportStreamInfo::create( | 
					
						
							| 
									
										
										
										
											2017-04-21 00:14:55 +02:00
										 |  |  |                     true, // Success
 | 
					
						
							| 
									
										
										
										
											2017-04-19 18:41:55 +02:00
										 |  |  |                     status.active, | 
					
						
							|  |  |  |                     status.fifoFilledCount, | 
					
						
							|  |  |  |                     status.fifoSize, | 
					
						
							|  |  |  |                     status.underrun, | 
					
						
							|  |  |  |                     status.overrun, | 
					
						
							|  |  |  |                     status.droppedPackets, | 
					
						
							|  |  |  |                     status.sampleRate, | 
					
						
							|  |  |  |                     status.linkRate, | 
					
						
							|  |  |  |                     status.timestamp); | 
					
						
							|  |  |  |             m_deviceAPI->getDeviceOutputMessageQueue()->push(report); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             MsgReportStreamInfo *report = MsgReportStreamInfo::create( | 
					
						
							| 
									
										
										
										
											2017-04-21 00:14:55 +02:00
										 |  |  |                     false, // Success
 | 
					
						
							|  |  |  |                     false, // status.active,
 | 
					
						
							|  |  |  |                     0,     // status.fifoFilledCount,
 | 
					
						
							|  |  |  |                     16384, // status.fifoSize,
 | 
					
						
							|  |  |  |                     0,     // status.underrun,
 | 
					
						
							|  |  |  |                     0,     // status.overrun,
 | 
					
						
							|  |  |  |                     0,     // status.droppedPackets,
 | 
					
						
							|  |  |  |                     0,     // status.sampleRate,
 | 
					
						
							|  |  |  |                     0,     // status.linkRate,
 | 
					
						
							|  |  |  |                     0);    // status.timestamp);
 | 
					
						
							| 
									
										
										
										
											2017-04-19 18:41:55 +02:00
										 |  |  |             m_deviceAPI->getDeviceOutputMessageQueue()->push(report); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool force) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     bool forwardChangeOwnDSP = false; | 
					
						
							|  |  |  |     bool forwardChangeRxDSP  = false; | 
					
						
							|  |  |  |     bool forwardChangeAllDSP = false; | 
					
						
							| 
									
										
										
										
											2017-04-20 00:01:11 +02:00
										 |  |  |     bool suspendOwnThread    = false; | 
					
						
							|  |  |  |     bool suspendRxThread     = false; | 
					
						
							|  |  |  |     bool suspendAllThread    = false; | 
					
						
							| 
									
										
										
										
											2017-04-18 13:50:28 +02:00
										 |  |  |     bool doCalibration = false; | 
					
						
							| 
									
										
										
										
											2017-04-23 16:23:01 +02:00
										 |  |  |     bool setAntennaAuto = false; | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  | //  QMutexLocker mutexLocker(&m_mutex);
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-20 00:01:11 +02:00
										 |  |  |     // determine if buddies threads or own thread need to be suspended
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         suspendAllThread = true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ((m_settings.m_log2HardDecim != settings.m_log2HardDecim) || | 
					
						
							|  |  |  |         (m_settings.m_centerFrequency != settings.m_centerFrequency) || force) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         suspendRxThread = true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-23 16:23:01 +02:00
										 |  |  |     if ((m_settings.m_antennaPath != settings.m_antennaPath) && | 
					
						
							|  |  |  |         (m_settings.m_antennaPath == 0)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         suspendRxThread = true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-20 00:01:11 +02:00
										 |  |  |     if ((m_settings.m_gain != settings.m_gain) || | 
					
						
							| 
									
										
										
										
											2017-04-19 08:34:27 +02:00
										 |  |  |         (m_settings.m_lpfBW != settings.m_lpfBW) || | 
					
						
							|  |  |  |         (m_settings.m_lpfFIRBW != settings.m_lpfFIRBW) || | 
					
						
							| 
									
										
										
										
											2017-04-20 18:21:01 +02:00
										 |  |  |         (m_settings.m_lpfFIREnable != settings.m_lpfFIREnable) || | 
					
						
							|  |  |  |         (m_settings.m_ncoEnable != settings.m_ncoEnable) || | 
					
						
							| 
									
										
										
										
											2017-04-23 16:23:01 +02:00
										 |  |  |         (m_settings.m_ncoFrequency != settings.m_ncoFrequency) || | 
					
						
							|  |  |  |         (m_settings.m_antennaPath != settings.m_antennaPath) || force) | 
					
						
							| 
									
										
										
										
											2017-04-19 08:34:27 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-04-20 00:01:11 +02:00
										 |  |  |         suspendOwnThread = true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // suspend buddies threads or own thread
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (suspendAllThread) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies(); | 
					
						
							|  |  |  |         std::vector<DeviceSourceAPI*>::const_iterator itSource = sourceBuddies.begin(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for (; itSource != sourceBuddies.end(); ++itSource) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSource)->getBuddySharedPtr(); | 
					
						
							| 
									
										
										
										
											2017-04-22 10:40:57 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if (buddySharedPtr->m_thread) { | 
					
						
							|  |  |  |                 buddySharedPtr->m_thread->stopWork(); | 
					
						
							| 
									
										
										
										
											2017-04-20 00:01:11 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         const std::vector<DeviceSinkAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies(); | 
					
						
							|  |  |  |         std::vector<DeviceSinkAPI*>::const_iterator itSink = sinkBuddies.begin(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for (; itSink != sinkBuddies.end(); ++itSink) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSink)->getBuddySharedPtr(); | 
					
						
							| 
									
										
										
										
											2017-04-22 10:40:57 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if (buddySharedPtr->m_thread) { | 
					
						
							|  |  |  |                 buddySharedPtr->m_thread->stopWork(); | 
					
						
							| 
									
										
										
										
											2017-04-20 00:01:11 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (m_limeSDRInputThread) { | 
					
						
							|  |  |  |             m_limeSDRInputThread->stopWork(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-19 08:34:27 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-04-20 00:01:11 +02:00
										 |  |  |     else if (suspendRxThread) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies(); | 
					
						
							|  |  |  |         std::vector<DeviceSourceAPI*>::const_iterator itSource = sourceBuddies.begin(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for (; itSource != sourceBuddies.end(); ++itSource) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSource)->getBuddySharedPtr(); | 
					
						
							| 
									
										
										
										
											2017-04-22 10:40:57 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if (buddySharedPtr->m_thread) { | 
					
						
							|  |  |  |                 buddySharedPtr->m_thread->stopWork(); | 
					
						
							| 
									
										
										
										
											2017-04-20 00:01:11 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (m_limeSDRInputThread) { | 
					
						
							|  |  |  |             m_limeSDRInputThread->stopWork(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (suspendOwnThread) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (m_limeSDRInputThread) { | 
					
						
							|  |  |  |             m_limeSDRInputThread->stopWork(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // apply settings
 | 
					
						
							| 
									
										
										
										
											2017-04-19 08:34:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |     if ((m_settings.m_dcBlock != settings.m_dcBlock) || force) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_settings.m_dcBlock = settings.m_dcBlock; | 
					
						
							|  |  |  |         m_deviceAPI->configureCorrections(m_settings.m_dcBlock, m_settings.m_iqCorrection); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ((m_settings.m_iqCorrection != settings.m_iqCorrection) || force) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_settings.m_iqCorrection = settings.m_iqCorrection; | 
					
						
							|  |  |  |         m_deviceAPI->configureCorrections(m_settings.m_dcBlock, m_settings.m_iqCorrection); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ((m_settings.m_gain != settings.m_gain) || force) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_settings.m_gain = settings.m_gain; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (m_deviceShared.m_deviceParams->getDevice() != 0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             if (LMS_SetGaindB(m_deviceShared.m_deviceParams->getDevice(), | 
					
						
							|  |  |  |                     LMS_CH_RX, | 
					
						
							|  |  |  |                     m_deviceShared.m_channel, | 
					
						
							|  |  |  |                     m_settings.m_gain) < 0) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 qDebug("LimeSDRInput::applySettings: LMS_SetGaindB() failed"); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2017-05-08 11:02:31 +02:00
										 |  |  |                 //doCalibration = true;
 | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |                 qDebug() << "LimeSDRInput::applySettings: Gain set to " << m_settings.m_gain; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ((m_settings.m_devSampleRate != settings.m_devSampleRate) | 
					
						
							|  |  |  |        || (m_settings.m_log2HardDecim != settings.m_log2HardDecim) || force) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         forwardChangeRxDSP  = m_settings.m_log2HardDecim != settings.m_log2HardDecim; | 
					
						
							|  |  |  |         forwardChangeAllDSP = m_settings.m_devSampleRate != settings.m_devSampleRate; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         m_settings.m_devSampleRate = settings.m_devSampleRate; | 
					
						
							|  |  |  |         m_settings.m_log2HardDecim = settings.m_log2HardDecim; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (m_deviceShared.m_deviceParams->getDevice() != 0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             if (LMS_SetSampleRateDir(m_deviceShared.m_deviceParams->getDevice(), | 
					
						
							|  |  |  |                     LMS_CH_RX, | 
					
						
							|  |  |  |                     m_settings.m_devSampleRate, | 
					
						
							|  |  |  |                     1<<m_settings.m_log2HardDecim) < 0) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 qCritical("LimeSDRInput::applySettings: could not set sample rate to %d with oversampling of %d", | 
					
						
							|  |  |  |                         m_settings.m_devSampleRate, | 
					
						
							|  |  |  |                         1<<m_settings.m_log2HardDecim); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 m_deviceShared.m_deviceParams->m_log2OvSRRx = m_settings.m_log2HardDecim; | 
					
						
							|  |  |  |                 m_deviceShared.m_deviceParams->m_sampleRate = m_settings.m_devSampleRate; | 
					
						
							| 
									
										
										
										
											2017-04-18 13:50:28 +02:00
										 |  |  |                 doCalibration = true; | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |                 qDebug("LimeSDRInput::applySettings: set sample rate set to %d with oversampling of %d", | 
					
						
							|  |  |  |                         m_settings.m_devSampleRate, | 
					
						
							|  |  |  |                         1<<m_settings.m_log2HardDecim); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ((m_settings.m_lpfBW != settings.m_lpfBW) || force) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_settings.m_lpfBW = settings.m_lpfBW; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (m_deviceShared.m_deviceParams->getDevice() != 0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             if (LMS_SetLPFBW(m_deviceShared.m_deviceParams->getDevice(), | 
					
						
							|  |  |  |                     LMS_CH_RX, | 
					
						
							|  |  |  |                     m_deviceShared.m_channel, | 
					
						
							|  |  |  |                     m_settings.m_lpfBW) < 0) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 qCritical("LimeSDRInput::applySettings: could not set LPF to %f Hz", m_settings.m_lpfBW); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2017-04-18 13:50:28 +02:00
										 |  |  |                 doCalibration = true; | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |                 qDebug("LimeSDRInput::applySettings: LPF set to %f Hz", m_settings.m_lpfBW); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ((m_settings.m_lpfFIRBW != settings.m_lpfFIRBW) || | 
					
						
							|  |  |  |         (m_settings.m_lpfFIREnable != settings.m_lpfFIREnable) || force) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_settings.m_lpfFIRBW = settings.m_lpfFIRBW; | 
					
						
							|  |  |  |         m_settings.m_lpfFIREnable = settings.m_lpfFIREnable; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (m_deviceShared.m_deviceParams->getDevice() != 0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             if (LMS_SetGFIRLPF(m_deviceShared.m_deviceParams->getDevice(), | 
					
						
							|  |  |  |                     LMS_CH_RX, | 
					
						
							|  |  |  |                     m_deviceShared.m_channel, | 
					
						
							|  |  |  |                     m_settings.m_lpfFIREnable, | 
					
						
							|  |  |  |                     m_settings.m_lpfFIRBW) < 0) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 qCritical("LimeSDRInput::applySettings: could %s and set LPF FIR to %f Hz", | 
					
						
							|  |  |  |                         m_settings.m_lpfFIREnable ? "enable" : "disable", | 
					
						
							|  |  |  |                         m_settings.m_lpfFIRBW); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2017-04-18 13:50:28 +02:00
										 |  |  |                 doCalibration = true; | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |                 qDebug("LimeSDRInput::applySettings: %sd and set LPF FIR to %f Hz", | 
					
						
							|  |  |  |                         m_settings.m_lpfFIREnable ? "enable" : "disable", | 
					
						
							|  |  |  |                         m_settings.m_lpfFIRBW); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-20 18:21:01 +02:00
										 |  |  |     if ((m_settings.m_ncoFrequency != settings.m_ncoFrequency) || | 
					
						
							|  |  |  |         (m_settings.m_ncoEnable != settings.m_ncoEnable) || force) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_settings.m_ncoFrequency = settings.m_ncoFrequency; | 
					
						
							|  |  |  |         m_settings.m_ncoEnable = settings.m_ncoEnable; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (m_deviceShared.m_deviceParams->getDevice() != 0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             if (DeviceLimeSDR::setNCOFrequency(m_deviceShared.m_deviceParams->getDevice(), | 
					
						
							|  |  |  |                     LMS_CH_RX, | 
					
						
							|  |  |  |                     m_deviceShared.m_channel, | 
					
						
							|  |  |  |                     m_settings.m_ncoEnable, | 
					
						
							|  |  |  |                     m_settings.m_ncoFrequency)) | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2017-05-08 11:02:31 +02:00
										 |  |  |                 //doCalibration = true;
 | 
					
						
							| 
									
										
										
										
											2017-04-20 23:02:06 +02:00
										 |  |  |                 forwardChangeOwnDSP = true; | 
					
						
							| 
									
										
										
										
											2017-04-20 23:43:24 +02:00
										 |  |  |                 m_deviceShared.m_ncoFrequency = m_settings.m_ncoEnable ? m_settings.m_ncoFrequency : 0; // for buddies
 | 
					
						
							| 
									
										
										
										
											2017-04-20 20:18:50 +02:00
										 |  |  |                 qDebug("LimeSDRInput::applySettings: %sd and set NCO to %d Hz", | 
					
						
							| 
									
										
										
										
											2017-04-20 18:21:01 +02:00
										 |  |  |                         m_settings.m_ncoEnable ? "enable" : "disable", | 
					
						
							|  |  |  |                         m_settings.m_ncoFrequency); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2017-04-20 20:18:50 +02:00
										 |  |  |                 qCritical("LimeSDRInput::applySettings: could not %s and set NCO to %d Hz", | 
					
						
							| 
									
										
										
										
											2017-04-20 18:21:01 +02:00
										 |  |  |                         m_settings.m_ncoEnable ? "enable" : "disable", | 
					
						
							|  |  |  |                         m_settings.m_ncoFrequency); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |     if ((m_settings.m_log2SoftDecim != settings.m_log2SoftDecim) || force) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_settings.m_log2SoftDecim = settings.m_log2SoftDecim; | 
					
						
							|  |  |  |         forwardChangeOwnDSP = true; | 
					
						
							| 
									
										
										
										
											2017-04-23 03:36:10 +02:00
										 |  |  |         m_deviceShared.m_log2Soft = m_settings.m_log2SoftDecim; // for buddies
 | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if (m_limeSDRInputThread != 0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             m_limeSDRInputThread->setLog2Decimation(m_settings.m_log2SoftDecim); | 
					
						
							|  |  |  |             qDebug() << "LimeSDRInput::applySettings: set soft decimation to " << (1<<m_settings.m_log2SoftDecim); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-23 16:23:01 +02:00
										 |  |  |     if ((m_settings.m_antennaPath != settings.m_antennaPath) || force) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_settings.m_antennaPath = settings.m_antennaPath; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (m_deviceShared.m_deviceParams->getDevice() != 0) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2017-05-07 01:47:31 +02:00
										 |  |  |             if (DeviceLimeSDR::setRxAntennaPath(m_deviceShared.m_deviceParams->getDevice(), | 
					
						
							| 
									
										
										
										
											2017-04-23 16:23:01 +02:00
										 |  |  |                     m_deviceShared.m_channel, | 
					
						
							|  |  |  |                     m_settings.m_antennaPath)) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 doCalibration = true; | 
					
						
							|  |  |  |                 setAntennaAuto = (m_settings.m_antennaPath == 0); | 
					
						
							|  |  |  |                 qDebug("LimeSDRInput::applySettings: set antenna path to %d", | 
					
						
							|  |  |  |                         (int) m_settings.m_antennaPath); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 qCritical("LimeSDRInput::applySettings: could not set antenna path to %d", | 
					
						
							|  |  |  |                         (int) m_settings.m_antennaPath); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || setAntennaAuto || force) | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         m_settings.m_centerFrequency = settings.m_centerFrequency; | 
					
						
							|  |  |  |         forwardChangeRxDSP = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (m_deviceShared.m_deviceParams->getDevice() != 0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             if (LMS_SetLOFrequency(m_deviceShared.m_deviceParams->getDevice(), | 
					
						
							|  |  |  |                     LMS_CH_RX, | 
					
						
							|  |  |  |                     m_deviceShared.m_channel, // same for both channels anyway but switches antenna port automatically
 | 
					
						
							| 
									
										
										
										
											2017-04-21 00:14:55 +02:00
										 |  |  |                     m_settings.m_centerFrequency) < 0) | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |             { | 
					
						
							|  |  |  |                 qCritical("LimeSDRInput::applySettings: could not set frequency to %lu", m_settings.m_centerFrequency); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2017-04-18 13:50:28 +02:00
										 |  |  |                 doCalibration = true; | 
					
						
							| 
									
										
										
										
											2017-04-21 00:14:55 +02:00
										 |  |  |                 m_deviceShared.m_centerFrequency = m_settings.m_centerFrequency; // for buddies
 | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |                 qDebug("LimeSDRInput::applySettings: frequency set to %lu", m_settings.m_centerFrequency); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-20 18:21:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-18 13:50:28 +02:00
										 |  |  |     if (doCalibration) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (LMS_Calibrate(m_deviceShared.m_deviceParams->getDevice(), | 
					
						
							|  |  |  |                 LMS_CH_RX, | 
					
						
							|  |  |  |                 m_deviceShared.m_channel, | 
					
						
							|  |  |  |                 m_settings.m_lpfBW, | 
					
						
							|  |  |  |                 0) < 0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             qCritical("LimeSDRInput::applySettings: calibration failed on Rx channel %lu", m_deviceShared.m_channel); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             qDebug("LimeSDRInput::applySettings: calibration successful on Rx channel %lu", m_deviceShared.m_channel); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-20 00:01:11 +02:00
										 |  |  |     // resume buddies threads or own thread
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (suspendAllThread) | 
					
						
							| 
									
										
										
										
											2017-04-18 23:26:30 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-04-20 00:01:11 +02:00
										 |  |  |         const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies(); | 
					
						
							|  |  |  |         std::vector<DeviceSourceAPI*>::const_iterator itSource = sourceBuddies.begin(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for (; itSource != sourceBuddies.end(); ++itSource) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSource)->getBuddySharedPtr(); | 
					
						
							| 
									
										
										
										
											2017-04-22 10:40:57 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if (buddySharedPtr->m_thread) { | 
					
						
							|  |  |  |                 buddySharedPtr->m_thread->startWork(); | 
					
						
							| 
									
										
										
										
											2017-04-20 00:01:11 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         const std::vector<DeviceSinkAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies(); | 
					
						
							|  |  |  |         std::vector<DeviceSinkAPI*>::const_iterator itSink = sinkBuddies.begin(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for (; itSink != sinkBuddies.end(); ++itSink) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSink)->getBuddySharedPtr(); | 
					
						
							| 
									
										
										
										
											2017-04-22 10:40:57 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if (buddySharedPtr->m_thread) { | 
					
						
							|  |  |  |                 buddySharedPtr->m_thread->startWork(); | 
					
						
							| 
									
										
										
										
											2017-04-20 00:01:11 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (m_limeSDRInputThread) { | 
					
						
							|  |  |  |             m_limeSDRInputThread->startWork(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-18 23:26:30 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-04-20 00:01:11 +02:00
										 |  |  |     else if (suspendRxThread) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies(); | 
					
						
							|  |  |  |         std::vector<DeviceSourceAPI*>::const_iterator itSource = sourceBuddies.begin(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for (; itSource != sourceBuddies.end(); ++itSource) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSource)->getBuddySharedPtr(); | 
					
						
							| 
									
										
										
										
											2017-04-22 10:40:57 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if (buddySharedPtr->m_thread) { | 
					
						
							|  |  |  |                 buddySharedPtr->m_thread->startWork(); | 
					
						
							| 
									
										
										
										
											2017-04-20 00:01:11 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (m_limeSDRInputThread) { | 
					
						
							|  |  |  |             m_limeSDRInputThread->startWork(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (suspendOwnThread) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (m_limeSDRInputThread) { | 
					
						
							|  |  |  |             m_limeSDRInputThread->startWork(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // forward changes to buddies or oneself
 | 
					
						
							| 
									
										
										
										
											2017-04-18 23:26:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |     if (forwardChangeAllDSP) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-04-19 01:04:57 +02:00
										 |  |  |         qDebug("LimeSDRInput::applySettings: forward change to all buddies"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-20 23:02:06 +02:00
										 |  |  |         int ncoShift = m_settings.m_ncoEnable ? m_settings.m_ncoFrequency : 0; | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // send to self first
 | 
					
						
							| 
									
										
										
										
											2017-04-23 03:36:10 +02:00
										 |  |  |         DSPSignalNotification *notif = new DSPSignalNotification( | 
					
						
							|  |  |  |                 m_settings.m_devSampleRate/(1<<m_settings.m_log2SoftDecim), | 
					
						
							|  |  |  |                 m_settings.m_centerFrequency + ncoShift); | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |         m_deviceAPI->getDeviceInputMessageQueue()->push(notif); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // send to source buddies
 | 
					
						
							| 
									
										
										
										
											2017-04-22 06:37:36 +02:00
										 |  |  |         const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies(); | 
					
						
							|  |  |  |         std::vector<DeviceSourceAPI*>::const_iterator itSource = sourceBuddies.begin(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |         for (; itSource != sourceBuddies.end(); ++itSource) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2017-04-20 23:43:24 +02:00
										 |  |  |             DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSource)->getBuddySharedPtr(); | 
					
						
							|  |  |  |             int buddyNCOFreq = buddySharedPtr->m_ncoFrequency; | 
					
						
							| 
									
										
										
										
											2017-04-23 03:36:10 +02:00
										 |  |  |             uint32_t buddyLog2Decim = buddySharedPtr->m_log2Soft; | 
					
						
							|  |  |  |             DSPSignalNotification *notif = new DSPSignalNotification( | 
					
						
							|  |  |  |                     m_settings.m_devSampleRate/(1<<buddyLog2Decim), | 
					
						
							|  |  |  |                     m_settings.m_centerFrequency + buddyNCOFreq); | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |             (*itSource)->getDeviceInputMessageQueue()->push(notif); | 
					
						
							|  |  |  |             MsgReportLimeSDRToGUI *report = MsgReportLimeSDRToGUI::create( | 
					
						
							|  |  |  |                     m_settings.m_centerFrequency, | 
					
						
							|  |  |  |                     m_settings.m_devSampleRate, | 
					
						
							|  |  |  |                     m_settings.m_log2HardDecim); | 
					
						
							| 
									
										
										
										
											2017-04-19 01:04:57 +02:00
										 |  |  |             (*itSource)->getDeviceOutputMessageQueue()->push(report); | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // send to sink buddies
 | 
					
						
							|  |  |  |         const std::vector<DeviceSinkAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies(); | 
					
						
							|  |  |  |         std::vector<DeviceSinkAPI*>::const_iterator itSink = sinkBuddies.begin(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for (; itSink != sinkBuddies.end(); ++itSink) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2017-04-21 00:14:55 +02:00
										 |  |  |             DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSink)->getBuddySharedPtr(); | 
					
						
							|  |  |  |             uint64_t buddyCenterFreq = buddySharedPtr->m_centerFrequency; | 
					
						
							|  |  |  |             int buddyNCOFreq = buddySharedPtr->m_ncoFrequency; | 
					
						
							| 
									
										
										
										
											2017-04-23 03:36:10 +02:00
										 |  |  |             uint32_t buddyLog2Interp = buddySharedPtr->m_log2Soft; | 
					
						
							|  |  |  |             DSPSignalNotification *notif = new DSPSignalNotification( | 
					
						
							|  |  |  |                     m_settings.m_devSampleRate/(1<<buddyLog2Interp), | 
					
						
							|  |  |  |                     buddyCenterFreq + buddyNCOFreq); // do not change center frequency
 | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |             (*itSink)->getDeviceInputMessageQueue()->push(notif); | 
					
						
							| 
									
										
										
										
											2017-04-23 03:36:10 +02:00
										 |  |  |             DeviceLimeSDRShared::MsgCrossReportToGUI *report = DeviceLimeSDRShared::MsgCrossReportToGUI::create(m_settings.m_devSampleRate); | 
					
						
							| 
									
										
										
										
											2017-04-19 01:04:57 +02:00
										 |  |  |             (*itSink)->getDeviceOutputMessageQueue()->push(report); | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (forwardChangeRxDSP) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-04-19 01:04:57 +02:00
										 |  |  |         qDebug("LimeSDRInput::applySettings: forward change to Rx buddies"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-18 13:33:33 +02:00
										 |  |  |         int sampleRate = m_settings.m_devSampleRate/(1<<m_settings.m_log2SoftDecim); | 
					
						
							| 
									
										
										
										
											2017-04-20 23:02:06 +02:00
										 |  |  |         int ncoShift = m_settings.m_ncoEnable ? m_settings.m_ncoFrequency : 0; | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // send to self first
 | 
					
						
							| 
									
										
										
										
											2017-04-20 23:02:06 +02:00
										 |  |  |         DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, m_settings.m_centerFrequency + ncoShift); | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |         m_deviceAPI->getDeviceInputMessageQueue()->push(notif); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // send to source buddies
 | 
					
						
							| 
									
										
										
										
											2017-04-22 06:37:36 +02:00
										 |  |  |         const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies(); | 
					
						
							|  |  |  |         std::vector<DeviceSourceAPI*>::const_iterator itSource = sourceBuddies.begin(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-20 23:43:24 +02:00
										 |  |  |         for (; itSource != sourceBuddies.end(); ++itSource) | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2017-04-20 23:43:24 +02:00
										 |  |  |             DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSource)->getBuddySharedPtr(); | 
					
						
							|  |  |  |             int buddyNCOFreq = buddySharedPtr->m_ncoFrequency; | 
					
						
							|  |  |  |             DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, m_settings.m_centerFrequency + buddyNCOFreq); | 
					
						
							|  |  |  |             (*itSource)->getDeviceInputMessageQueue()->push(notif); | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |             MsgReportLimeSDRToGUI *report = MsgReportLimeSDRToGUI::create( | 
					
						
							|  |  |  |                     m_settings.m_centerFrequency, | 
					
						
							|  |  |  |                     m_settings.m_devSampleRate, | 
					
						
							|  |  |  |                     m_settings.m_log2HardDecim); | 
					
						
							| 
									
										
										
										
											2017-04-20 23:43:24 +02:00
										 |  |  |             (*itSource)->getDeviceOutputMessageQueue()->push(report); | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (forwardChangeOwnDSP) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-04-19 01:04:57 +02:00
										 |  |  |         qDebug("LimeSDRInput::applySettings: forward change to self only"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-18 13:33:33 +02:00
										 |  |  |         int sampleRate = m_settings.m_devSampleRate/(1<<m_settings.m_log2SoftDecim); | 
					
						
							| 
									
										
										
										
											2017-04-20 23:02:06 +02:00
										 |  |  |         int ncoShift = m_settings.m_ncoEnable ? m_settings.m_ncoFrequency : 0; | 
					
						
							|  |  |  |         DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, m_settings.m_centerFrequency + ncoShift); | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  |         m_deviceAPI->getDeviceInputMessageQueue()->push(notif); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     qDebug() << "LimeSDRInput::applySettings: center freq: " << m_settings.m_centerFrequency << " Hz" | 
					
						
							| 
									
										
										
										
											2017-04-18 13:33:33 +02:00
										 |  |  |             << " device stream sample rate: " << m_settings.m_devSampleRate << "S/s" | 
					
						
							|  |  |  |             << " sample rate with soft decimation: " << m_settings.m_devSampleRate/(1<<m_settings.m_log2SoftDecim) << "S/s"; | 
					
						
							| 
									
										
										
										
											2017-04-18 02:12:15 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 |