mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-11-03 21:20:31 -05:00 
			
		
		
		
	SDRdaemon plugin: send configuration done
This commit is contained in:
		
							parent
							
								
									0822773fbb
								
							
						
					
					
						commit
						17db3e03b6
					
				
							
								
								
									
										28
									
								
								cmake/Modules/FindLibNANOMSG.cmake
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								cmake/Modules/FindLibNANOMSG.cmake
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,28 @@
 | 
				
			|||||||
 | 
					if(NOT LIBNANOMSG_FOUND)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  pkg_check_modules (LIBNANOMSG_PKG libnanomsg)
 | 
				
			||||||
 | 
					  find_path(LIBNANOMSG_INCLUDE_DIR NAMES nanomsg/nn.h
 | 
				
			||||||
 | 
					    PATHS
 | 
				
			||||||
 | 
					    ${LIBNANOMSG_PKG_INCLUDE_DIRS}
 | 
				
			||||||
 | 
					    /usr/include
 | 
				
			||||||
 | 
					    /usr/local/include
 | 
				
			||||||
 | 
					  )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  find_library(LIBNANOMSG_LIBRARIES NAMES nanomsg
 | 
				
			||||||
 | 
					    PATHS
 | 
				
			||||||
 | 
					    ${LIBNANOMSG_PKG_LIBRARY_DIRS}
 | 
				
			||||||
 | 
					    /usr/lib
 | 
				
			||||||
 | 
					    /usr/local/lib
 | 
				
			||||||
 | 
					  )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if(LIBNANOMSG_INCLUDE_DIR AND LIBNANOMSG_LIBRARIES)
 | 
				
			||||||
 | 
					    set(LIBNANOMSG_FOUND TRUE CACHE INTERNAL "libnanomsg found")
 | 
				
			||||||
 | 
					    message(STATUS "Found libnanomsg: ${LIBNANOMSG_INCLUDE_DIR}, ${LIBNANOMSG_LIBRARIES}")
 | 
				
			||||||
 | 
					  else(LIBNANOMSG_INCLUDE_DIR AND LIBNANOMSG_LIBRARIES)
 | 
				
			||||||
 | 
					    set(LIBNANOMSG_FOUND FALSE CACHE INTERNAL "libnanomsg found")
 | 
				
			||||||
 | 
					    message(STATUS "libnanomsg not found.")
 | 
				
			||||||
 | 
					  endif(LIBNANOMSG_INCLUDE_DIR AND LIBNANOMSG_LIBRARIES)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  mark_as_advanced(LIBNANOMSG_INCLUDE_DIR LIBNANOMSG_LIBRARIES)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					endif(NOT LIBNANOMSG_FOUND)
 | 
				
			||||||
@ -42,5 +42,11 @@ if(LIBUSB_FOUND AND LIBHACKRF_FOUND)
 | 
				
			|||||||
	add_subdirectory(hackrf)
 | 
						add_subdirectory(hackrf)
 | 
				
			||||||
endif(LIBUSB_FOUND AND LIBHACKRF_FOUND)
 | 
					endif(LIBUSB_FOUND AND LIBHACKRF_FOUND)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#find_package(LibNANOMSG)
 | 
				
			||||||
 | 
					#if(LIBNANOMSG_FOUND)
 | 
				
			||||||
 | 
					#    add_subdirectory(sdrdaemon)    
 | 
				
			||||||
 | 
					#endif(LIBNANOMSG_FOUND)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_subdirectory(filesource)
 | 
					add_subdirectory(filesource)
 | 
				
			||||||
add_subdirectory(sdrdaemon)
 | 
					add_subdirectory(sdrdaemon)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,7 @@
 | 
				
			|||||||
project(sdrdaemon)
 | 
					project(sdrdaemon)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
find_package(LZ4)
 | 
					find_package(LZ4)
 | 
				
			||||||
 | 
					find_package(LibNANOMSG)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set(sdrdaemon_SOURCES
 | 
					set(sdrdaemon_SOURCES
 | 
				
			||||||
    sdrdaemonbuffer.cpp
 | 
					    sdrdaemonbuffer.cpp
 | 
				
			||||||
@ -45,11 +46,13 @@ add_library(inputsdrdaemon SHARED
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
target_include_directories(inputsdrdaemon PUBLIC
 | 
					target_include_directories(inputsdrdaemon PUBLIC
 | 
				
			||||||
    ${LZ4_INCLUDE_DIRS}
 | 
					    ${LZ4_INCLUDE_DIRS}
 | 
				
			||||||
 | 
					    ${LIBNANOMSG_INCLUDE_DIR}
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
target_link_libraries(inputsdrdaemon
 | 
					target_link_libraries(inputsdrdaemon
 | 
				
			||||||
	${QT_LIBRARIES}
 | 
						${QT_LIBRARIES}
 | 
				
			||||||
	${LZ4_LIBRARIES}
 | 
						${LZ4_LIBRARIES}
 | 
				
			||||||
 | 
						${LIBNANOMSG_LIBRARIES}
 | 
				
			||||||
	sdrbase
 | 
						sdrbase
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -67,6 +67,12 @@ SDRdaemonGui::SDRdaemonGui(PluginAPI* pluginAPI, QWidget* parent) :
 | 
				
			|||||||
	m_iqCorrection(false),
 | 
						m_iqCorrection(false),
 | 
				
			||||||
	m_autoFollowRate(false)
 | 
						m_autoFollowRate(false)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						m_sender = nn_socket(AF_SP, NN_PAIR);
 | 
				
			||||||
 | 
						assert(m_sender != -1);
 | 
				
			||||||
 | 
						int millis = 500;
 | 
				
			||||||
 | 
					    int rc = nn_setsockopt (m_sender, NN_SOL_SOCKET, NN_SNDTIMEO, &millis, sizeof (millis));
 | 
				
			||||||
 | 
					    assert (rc == 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	m_startingTimeStamp.tv_sec = 0;
 | 
						m_startingTimeStamp.tv_sec = 0;
 | 
				
			||||||
	m_startingTimeStamp.tv_usec = 0;
 | 
						m_startingTimeStamp.tv_usec = 0;
 | 
				
			||||||
	ui->setupUi(this);
 | 
						ui->setupUi(this);
 | 
				
			||||||
@ -383,6 +389,7 @@ void SDRdaemonGui::on_applyButton_clicked(bool checked)
 | 
				
			|||||||
void SDRdaemonGui::on_sendButton_clicked(bool checked)
 | 
					void SDRdaemonGui::on_sendButton_clicked(bool checked)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	sendConfiguration();
 | 
						sendConfiguration();
 | 
				
			||||||
 | 
						ui->specificParms->setCursorPosition(0);
 | 
				
			||||||
	ui->sendButton->setEnabled(false);
 | 
						ui->sendButton->setEnabled(false);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -394,6 +401,16 @@ void SDRdaemonGui::sendConfiguration()
 | 
				
			|||||||
	if (remoteAddress != m_remoteAddress)
 | 
						if (remoteAddress != m_remoteAddress)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		m_remoteAddress = remoteAddress;
 | 
							m_remoteAddress = remoteAddress;
 | 
				
			||||||
 | 
							std::ostringstream os;
 | 
				
			||||||
 | 
							os << "tcp://" << m_remoteAddress.toStdString() << ":" << m_controlPort;
 | 
				
			||||||
 | 
							std::string addrstrng = os.str();
 | 
				
			||||||
 | 
						    int rc = nn_connect(m_sender, addrstrng.c_str());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						    if (rc < 0) {
 | 
				
			||||||
 | 
						    	QMessageBox::information(this, tr("Message"), tr("Cannot connect to remote control port"));
 | 
				
			||||||
 | 
						    } else {
 | 
				
			||||||
 | 
						    	qDebug() << "SDRdaemonGui::sendConfiguration: connexion to " << addrstrng.c_str() << " successful";
 | 
				
			||||||
 | 
						    }
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	std::ostringstream os;
 | 
						std::ostringstream os;
 | 
				
			||||||
@ -422,9 +439,19 @@ void SDRdaemonGui::sendConfiguration()
 | 
				
			|||||||
		os << "," << ui->specificParms->text().toStdString();
 | 
							os << "," << ui->specificParms->text().toStdString();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	qDebug() << "SDRdaemonGui::sendConfiguration:"
 | 
					    int config_size = os.str().size();
 | 
				
			||||||
		<< " remoteAddress: " << remoteAddress
 | 
					    int rc = nn_send(m_sender, (void *) os.str().c_str(), config_size, 0);
 | 
				
			||||||
		<< " message: " << os.str().c_str();
 | 
					
 | 
				
			||||||
 | 
					    if (rc != config_size)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					    	QMessageBox::information(this, tr("Message"), tr("Cannot send message to remote control port"));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					    	qDebug() << "SDRdaemonGui::sendConfiguration:"
 | 
				
			||||||
 | 
					    		<< " remoteAddress: " << remoteAddress
 | 
				
			||||||
 | 
					    		<< " message: " << os.str().c_str();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void SDRdaemonGui::on_address_textEdited(const QString& arg1)
 | 
					void SDRdaemonGui::on_address_textEdited(const QString& arg1)
 | 
				
			||||||
@ -546,16 +573,16 @@ void SDRdaemonGui::updateWithStreamData()
 | 
				
			|||||||
	QString s2 = QString::number(skewPerCent, 'f', 2);
 | 
						QString s2 = QString::number(skewPerCent, 'f', 2);
 | 
				
			||||||
	ui->skewRateText->setText(tr("%1").arg(s2));
 | 
						ui->skewRateText->setText(tr("%1").arg(s2));
 | 
				
			||||||
	updateWithStreamTime();
 | 
						updateWithStreamTime();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void SDRdaemonGui::updateWithStreamTime()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
	if (m_initSendConfiguration)
 | 
						if (m_initSendConfiguration)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		sendConfiguration();
 | 
							sendConfiguration();
 | 
				
			||||||
		m_initSendConfiguration = false;
 | 
							m_initSendConfiguration = false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
void SDRdaemonGui::updateWithStreamTime()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    quint64 startingTimeStampMsec = ((quint64) m_startingTimeStamp.tv_sec * 1000LL) + ((quint64) m_startingTimeStamp.tv_usec / 1000LL);
 | 
					    quint64 startingTimeStampMsec = ((quint64) m_startingTimeStamp.tv_sec * 1000LL) + ((quint64) m_startingTimeStamp.tv_usec / 1000LL);
 | 
				
			||||||
    QDateTime dt = QDateTime::fromMSecsSinceEpoch(startingTimeStampMsec);
 | 
					    QDateTime dt = QDateTime::fromMSecsSinceEpoch(startingTimeStampMsec);
 | 
				
			||||||
    QString s_date = dt.toString("yyyy-MM-dd  hh:mm:ss.zzz");
 | 
					    QString s_date = dt.toString("yyyy-MM-dd  hh:mm:ss.zzz");
 | 
				
			||||||
 | 
				
			|||||||
@ -78,6 +78,7 @@ private:
 | 
				
			|||||||
	bool m_addressEdited;
 | 
						bool m_addressEdited;
 | 
				
			||||||
	bool m_dataPortEdited;
 | 
						bool m_dataPortEdited;
 | 
				
			||||||
	bool m_initSendConfiguration;
 | 
						bool m_initSendConfiguration;
 | 
				
			||||||
 | 
						int m_sender;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bool m_dcBlock;
 | 
						bool m_dcBlock;
 | 
				
			||||||
	bool m_iqCorrection;
 | 
						bool m_iqCorrection;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user