SDRdaemon plugin: send configuration done

pull/6/head
f4exb 2016-03-27 04:33:12 +02:00
rodzic 0822773fbb
commit 17db3e03b6
5 zmienionych plików z 71 dodań i 6 usunięć

Wyświetl plik

@ -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)

Wyświetl plik

@ -42,5 +42,11 @@ if(LIBUSB_FOUND AND LIBHACKRF_FOUND)
add_subdirectory(hackrf)
endif(LIBUSB_FOUND AND LIBHACKRF_FOUND)
#find_package(LibNANOMSG)
#if(LIBNANOMSG_FOUND)
# add_subdirectory(sdrdaemon)
#endif(LIBNANOMSG_FOUND)
add_subdirectory(filesource)
add_subdirectory(sdrdaemon)

Wyświetl plik

@ -1,6 +1,7 @@
project(sdrdaemon)
find_package(LZ4)
find_package(LibNANOMSG)
set(sdrdaemon_SOURCES
sdrdaemonbuffer.cpp
@ -45,11 +46,13 @@ add_library(inputsdrdaemon SHARED
target_include_directories(inputsdrdaemon PUBLIC
${LZ4_INCLUDE_DIRS}
${LIBNANOMSG_INCLUDE_DIR}
)
target_link_libraries(inputsdrdaemon
${QT_LIBRARIES}
${LZ4_LIBRARIES}
${LIBNANOMSG_LIBRARIES}
sdrbase
)

Wyświetl plik

@ -67,6 +67,12 @@ SDRdaemonGui::SDRdaemonGui(PluginAPI* pluginAPI, QWidget* parent) :
m_iqCorrection(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_usec = 0;
ui->setupUi(this);
@ -383,6 +389,7 @@ void SDRdaemonGui::on_applyButton_clicked(bool checked)
void SDRdaemonGui::on_sendButton_clicked(bool checked)
{
sendConfiguration();
ui->specificParms->setCursorPosition(0);
ui->sendButton->setEnabled(false);
}
@ -394,6 +401,16 @@ void SDRdaemonGui::sendConfiguration()
if (remoteAddress != m_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;
@ -422,9 +439,19 @@ void SDRdaemonGui::sendConfiguration()
os << "," << ui->specificParms->text().toStdString();
}
qDebug() << "SDRdaemonGui::sendConfiguration:"
<< " remoteAddress: " << remoteAddress
<< " message: " << os.str().c_str();
int config_size = os.str().size();
int rc = nn_send(m_sender, (void *) os.str().c_str(), config_size, 0);
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)
@ -546,16 +573,16 @@ void SDRdaemonGui::updateWithStreamData()
QString s2 = QString::number(skewPerCent, 'f', 2);
ui->skewRateText->setText(tr("%1").arg(s2));
updateWithStreamTime();
}
void SDRdaemonGui::updateWithStreamTime()
{
if (m_initSendConfiguration)
{
sendConfiguration();
m_initSendConfiguration = false;
}
}
void SDRdaemonGui::updateWithStreamTime()
{
quint64 startingTimeStampMsec = ((quint64) m_startingTimeStamp.tv_sec * 1000LL) + ((quint64) m_startingTimeStamp.tv_usec / 1000LL);
QDateTime dt = QDateTime::fromMSecsSinceEpoch(startingTimeStampMsec);
QString s_date = dt.toString("yyyy-MM-dd hh:mm:ss.zzz");

Wyświetl plik

@ -78,6 +78,7 @@ private:
bool m_addressEdited;
bool m_dataPortEdited;
bool m_initSendConfiguration;
int m_sender;
bool m_dcBlock;
bool m_iqCorrection;