From ba790cba2f7b48dd66f4418de0b7b366422926b0 Mon Sep 17 00:00:00 2001 From: Jörgen Scott Date: Tue, 13 Jan 2015 11:27:39 +0100 Subject: added zmq remote control --- src/RemoteControl.h | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 129 insertions(+), 2 deletions(-) (limited to 'src/RemoteControl.h') diff --git a/src/RemoteControl.h b/src/RemoteControl.h index 09e7492..7c830b2 100644 --- a/src/RemoteControl.h +++ b/src/RemoteControl.h @@ -29,6 +29,14 @@ #ifndef _REMOTECONTROL_H #define _REMOTECONTROL_H +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#if defined(HAVE_INPUT_ZEROMQ) +#include +#endif + #include #include #include @@ -85,6 +93,42 @@ class BaseRemoteController { virtual ~BaseRemoteController() {} }; +class RemoteControllers { +/* Holds all our remote controllers, i.e. we may have more than + * one type of controller running. +*/ + public: + RemoteControllers() {} + virtual ~RemoteControllers() {} + + void add_controller(BaseRemoteController *rc) { + m_controllers.push_back(rc); + } + + void add_controllable(RemoteControllable *rc) { + for (std::list::iterator it = m_controllers.begin(); + it != m_controllers.end(); ++it) { + (*it)->enrol(rc); + } + } + + void check_faults() { + for (std::list::iterator it = m_controllers.begin(); + it != m_controllers.end(); ++it) { + if ((*it)->fault_detected()) + { + fprintf(stderr, + "Detected Remote Control fault, restarting it\n"); + (*it)->restart(); + } + } + } + size_t get_no_controllers() { return m_controllers.size(); } + + private: + std::list m_controllers; +}; + /* Objects that support remote control must implement the following class */ class RemoteControllable { public: @@ -100,8 +144,8 @@ class RemoteControllable { virtual std::string get_rc_name() const { return m_name; } /* Tell the controllable to enrol at the given controller */ - virtual void enrol_at(BaseRemoteController& controller) { - controller.enrol(this); + virtual void enrol_at(RemoteControllers& controllers) { + controllers.add_controllable(this); } /* Return a list of possible parameters that can be set */ @@ -254,6 +298,89 @@ class RemoteControllerTelnet : public BaseRemoteController { int m_port; }; +#if defined(HAVE_INPUT_ZEROMQ) +/* Implements a Remote controller using zmq transportlayer + * that listens on localhost + */ +class RemoteControllerZmq : public BaseRemoteController { + public: + RemoteControllerZmq() + : m_running(false), m_fault(false), + m_zmqContext(1), + m_endpoint("") { } + + RemoteControllerZmq(std::string endpoint) + : m_running(true), m_fault(false), + m_child_thread(&RemoteControllerZmq::process, this), + m_zmqContext(1), + m_endpoint(endpoint) + { } + + ~RemoteControllerZmq() { + m_running = false; + m_fault = false; + if (!m_endpoint.empty()) { + m_child_thread.interrupt(); + m_child_thread.join(); + } + } + + void enrol(RemoteControllable* controllable) { + m_cohort.push_back(controllable); + } + + virtual bool fault_detected() { return m_fault; } + + virtual void restart(); + + private: + void restart_thread(); + + void recv_all(zmq::socket_t* pSocket, std::vector &message); + void send_ok_reply(zmq::socket_t *pSocket); + void send_fail_reply(zmq::socket_t *pSocket, const std::string &error); + void process(); + + + RemoteControllerZmq& operator=(const RemoteControllerZmq& other); + RemoteControllerZmq(const RemoteControllerZmq& other); + + RemoteControllable* get_controllable_(std::string name) { + for (std::list::iterator it = m_cohort.begin(); + it != m_cohort.end(); ++it) { + if ((*it)->get_rc_name() == name) + { + return *it; + } + } + throw ParameterError("Module name unknown"); + } + + std::string get_param_(std::string name, std::string param) { + RemoteControllable* controllable = get_controllable_(name); + return controllable->get_parameter(param); + } + + void set_param_(std::string name, std::string param, std::string value) { + RemoteControllable* controllable = get_controllable_(name); + return controllable->set_parameter(param, value); + } + + bool m_running; + + /* This is set to true if a fault occurred */ + bool m_fault; + boost::thread m_restarter_thread; + + boost::thread m_child_thread; + + /* This controller commands the controllables in the cohort */ + std::list m_cohort; + + zmq::context_t m_zmqContext; + std::string m_endpoint; +}; +#endif /* The Dummy remote controller does nothing, and never fails */ -- cgit v1.2.3 From d82422fbb3d9d34a0566197245376548ce3ef14e Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 23 Jan 2015 10:15:34 +0100 Subject: Code indentation, minor corrections --- doc/example.ini | 13 ++-- src/DabMod.cpp | 14 +--- src/OutputUHD.cpp | 56 +++++++------- src/OutputUHD.h | 8 +- src/RemoteControl.cpp | 197 +++++++++++++++++++++++++------------------------- src/RemoteControl.h | 64 ++++++++-------- 6 files changed, 172 insertions(+), 180 deletions(-) (limited to 'src/RemoteControl.h') diff --git a/doc/example.ini b/doc/example.ini index 9a80eeb..ecb7440 100644 --- a/doc/example.ini +++ b/doc/example.ini @@ -9,14 +9,15 @@ telnet=1 telnetport=2121 ; Enable zmq remote control. -; The zmq remote control is intended for machine-to-machine -; integration and requires that the odr-mod is build with zmq support. -; The zmq remote control may run in parallell with Telnet. +; The zmq remote control is intended for machine-to-machine +; integration and requires that ODR-DabMod is built with zmq support. +; The zmq remote control may run in parallel with Telnet. +; ; Protocol: -; The odr-dabmod binds a zmq rep socket so clients must connect +; ODR-DabMod binds a zmq rep socket so clients must connect ; using either req or dealer socket. ; [] denotes message part as zmq multi-part message are used for delimitation. -; All message parts are utf-8 encoded strings and matches the Telnet command set. +; All message parts are utf-8 encoded strings and match the Telnet command set. ; Explicit codes are denoted with "". ; The following commands are supported: ; REQ: ["ping"] @@ -163,7 +164,7 @@ channel=13C ; The reference clock to use. ; possible values : internal, external, MIMO -refclk_source=external +refclk_source=internal ; The reference one pulse-per second to use ; possible values : none, external, MIMO diff --git a/src/DabMod.cpp b/src/DabMod.cpp index dadade9..ea6334f 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -55,7 +55,6 @@ #include #include #include -//#include #ifdef HAVE_NETINET_IN_H # include @@ -190,9 +189,6 @@ int main(int argc, char* argv[]) OutputUHDConfig outputuhd_conf; #endif - //zmq::context_t zmqCtrlContext(1); - //std::string zmqCtrlEndpoint = ""; - // To handle the timestamp offset of the modulator struct modulator_offset_config modconf; modconf.use_offset_file = false; @@ -204,7 +200,6 @@ int main(int argc, char* argv[]) InputMemory* input = NULL; ModOutput* output = NULL; - //BaseRemoteController* rc = NULL; RemoteControllers rcs; Logger logger; @@ -371,9 +366,8 @@ int main(int argc, char* argv[]) #if defined(HAVE_INPUT_ZEROMQ) if (pt.get("remotecontrol.zmqctrl", 0) == 1) { try { - std::string zmqCtrlEndpoint = - pt.get("remotecontrol.zmqctrlendpoint", ""); - std::cout << "ZmqCtrlEndpoint: " << zmqCtrlEndpoint << std::endl; + std::string zmqCtrlEndpoint = pt.get("remotecontrol.zmqctrlendpoint", ""); + std::cerr << "ZmqCtrlEndpoint: " << zmqCtrlEndpoint << std::endl; RemoteControllerZmq* zmqrc = new RemoteControllerZmq(zmqCtrlEndpoint); rcs.add_controller(zmqrc); } @@ -720,7 +714,7 @@ int main(int argc, char* argv[]) outputuhd_conf.sampleRate = outputRate; try { - output = new OutputUHD(outputuhd_conf, logger/*, &zmqCtrlContext, zmqCtrlEndpoint*/); + output = new OutputUHD(outputuhd_conf, logger); ((OutputUHD*)output)->enrol_at(rcs); } catch (std::exception& e) { @@ -773,7 +767,7 @@ int main(int argc, char* argv[]) /* Check every once in a while if the remote control * is still working */ if (rcs.get_no_controllers() > 0 && (frame % 250) == 0) { - rcs.check_faults(); + rcs.check_faults(); } } if (framesize == 0) { diff --git a/src/OutputUHD.cpp b/src/OutputUHD.cpp index 4776965..c7770fa 100644 --- a/src/OutputUHD.cpp +++ b/src/OutputUHD.cpp @@ -54,7 +54,7 @@ OutputUHD::OutputUHD( // the buffers at object initialisation. first_run(true), activebuffer(1), - myDelayBuf(196608) + myDelayBuf(196608) { myMuting = 0; // is remote-controllable @@ -233,10 +233,10 @@ OutputUHD::~OutputUHD() { MDEBUG("OutputUHD::~OutputUHD() @ %p\n", this); worker.stop(); - if (!first_run) { - free(uwd.frame0.buf); - free(uwd.frame1.buf); - } + if (!first_run) { + free(uwd.frame0.buf); + free(uwd.frame1.buf); + } } int OutputUHD::process(Buffer* dataIn, Buffer* dataOut) @@ -291,31 +291,31 @@ int OutputUHD::process(Buffer* dataIn, Buffer* dataOut) uwd.sourceContainsTimestamp = myConf.enableSync && myEtiReader->sourceContainsTimestamp(); - // calculate delay - uint32_t noSampleDelay = (myStaticDelay * 2048) / 1000; - uint32_t noByteDelay = noSampleDelay * sizeof(complexf); + // calculate delay + uint32_t noSampleDelay = (myStaticDelay * 2048) / 1000; + uint32_t noByteDelay = noSampleDelay * sizeof(complexf); - uint8_t* pInData = (uint8_t*) dataIn->getData(); + uint8_t* pInData = (uint8_t*) dataIn->getData(); if (activebuffer == 0) { - uint8_t *pTmp = (uint8_t*) uwd.frame0.buf; - // copy remain from delaybuf + uint8_t *pTmp = (uint8_t*) uwd.frame0.buf; + // copy remain from delaybuf memcpy(pTmp, &myDelayBuf[0], noByteDelay); - // copy new data + // copy new data memcpy(&pTmp[noByteDelay], pInData, uwd.bufsize - noByteDelay); - // copy remaining data to delay buf - memcpy(&myDelayBuf[0], &pInData[uwd.bufsize - noByteDelay], noByteDelay); + // copy remaining data to delay buf + memcpy(&myDelayBuf[0], &pInData[uwd.bufsize - noByteDelay], noByteDelay); uwd.frame0.ts = ts; uwd.frame0.fct = myEtiReader->getFCT(); } else if (activebuffer == 1) { - uint8_t *pTmp = (uint8_t*) uwd.frame1.buf; - // copy remain from delaybuf + uint8_t *pTmp = (uint8_t*) uwd.frame1.buf; + // copy remain from delaybuf memcpy(pTmp, &myDelayBuf[0], noByteDelay); - // copy new data + // copy new data memcpy(&pTmp[noByteDelay], pInData, uwd.bufsize - noByteDelay); - // copy remaining data to delay buf - memcpy(&myDelayBuf[0], &pInData[uwd.bufsize - noByteDelay], noByteDelay); + // copy remaining data to delay buf + memcpy(&myDelayBuf[0], &pInData[uwd.bufsize - noByteDelay], noByteDelay); uwd.frame1.ts = ts; uwd.frame1.fct = myEtiReader->getFCT(); @@ -617,15 +617,15 @@ void OutputUHD::set_parameter(const string& parameter, const string& value) ss >> myMuting; } else if (parameter == "staticdelay") { - int adjust; - ss >> adjust; - int newStaticDelay = myStaticDelay + adjust; - if (newStaticDelay > 96000) - myStaticDelay = newStaticDelay - 96000; - else if (newStaticDelay < 0) - myStaticDelay = newStaticDelay + 96000; - else - myStaticDelay = newStaticDelay; + int adjust; + ss >> adjust; + int newStaticDelay = myStaticDelay + adjust; + if (newStaticDelay > 96000) + myStaticDelay = newStaticDelay - 96000; + else if (newStaticDelay < 0) + myStaticDelay = newStaticDelay + 96000; + else + myStaticDelay = newStaticDelay; } else if (parameter == "iqbalance") { ss >> myConf.frequency; diff --git a/src/OutputUHD.h b/src/OutputUHD.h index 60dfc65..90d9d1b 100644 --- a/src/OutputUHD.h +++ b/src/OutputUHD.h @@ -222,10 +222,10 @@ class OutputUHD: public ModOutput, public RemoteControllable { // muting can only be changed using the remote control bool myMuting; - private: - // data - int myStaticDelay; - std::vector myDelayBuf; + private: + // data + int myStaticDelay; + std::vector myDelayBuf; size_t lastLen; }; diff --git a/src/RemoteControl.cpp b/src/RemoteControl.cpp index c7c5914..6f538dc 100644 --- a/src/RemoteControl.cpp +++ b/src/RemoteControl.cpp @@ -271,120 +271,121 @@ void RemoteControllerZmq::restart_thread() void RemoteControllerZmq::recv_all(zmq::socket_t* pSocket, std::vector &message) { - int more = -1; - size_t more_size = sizeof(more); - - while (more != 0) - { - zmq::message_t msg; - pSocket->recv(&msg); - message.push_back(std::string((char*)msg.data(), msg.size())); - pSocket->getsockopt(ZMQ_RCVMORE, &more, &more_size); - } + int more = -1; + size_t more_size = sizeof(more); + + while (more != 0) + { + zmq::message_t msg; + pSocket->recv(&msg); + message.push_back(std::string((char*)msg.data(), msg.size())); + pSocket->getsockopt(ZMQ_RCVMORE, &more, &more_size); + } } void RemoteControllerZmq::send_ok_reply(zmq::socket_t *pSocket) { - zmq::message_t msg(2); - char repCode[2] = {'o', 'k'}; - memcpy ((void*) msg.data(), repCode, 2); - pSocket->send(msg, 0); + zmq::message_t msg(2); + char repCode[2] = {'o', 'k'}; + memcpy ((void*) msg.data(), repCode, 2); + pSocket->send(msg, 0); } void RemoteControllerZmq::send_fail_reply(zmq::socket_t *pSocket, const std::string &error) { - zmq::message_t msg1(4); - char repCode[4] = {'f', 'a', 'i', 'l'}; - memcpy ((void*) msg1.data(), repCode, 4); - pSocket->send(msg1, ZMQ_SNDMORE); - - zmq::message_t msg2(error.length()); - memcpy ((void*) msg2.data(), error.c_str(), error.length()); - pSocket->send(msg2, 0); + zmq::message_t msg1(4); + char repCode[4] = {'f', 'a', 'i', 'l'}; + memcpy ((void*) msg1.data(), repCode, 4); + pSocket->send(msg1, ZMQ_SNDMORE); + + zmq::message_t msg2(error.length()); + memcpy ((void*) msg2.data(), error.c_str(), error.length()); + pSocket->send(msg2, 0); } void RemoteControllerZmq::process() { - // create zmq reply socket for receiving ctrl parameters - zmq::socket_t repSocket(m_zmqContext, ZMQ_REP); - std::cout << "Starting zmq remote control thread" << std::endl; - try - { - // connect the socket - int hwm = 100; - int linger = 0; - repSocket.setsockopt(ZMQ_RCVHWM, &hwm, sizeof(hwm)); - repSocket.setsockopt(ZMQ_SNDHWM, &hwm, sizeof(hwm)); - repSocket.setsockopt(ZMQ_LINGER, &linger, sizeof(linger)); - repSocket.bind(m_endpoint.c_str()); - - // create pollitem that polls the ZMQ sockets - zmq::pollitem_t pollItems[] = { {repSocket, 0, ZMQ_POLLIN, 0} }; - for(;;) - { - zmq::poll(pollItems, 1, 100); - std::vector msg; - if (pollItems[0].revents & ZMQ_POLLIN) - { - recv_all(&repSocket, msg); - std::string command((char*)msg[0].data(), msg[0].size()); - - if (msg.size() == 1 && command == "ping") - { - send_ok_reply(&repSocket); - } - else if (msg.size() == 3 && command == "get") - { - std::string module((char*) msg[1].data(), msg[1].size()); - std::string parameter((char*) msg[2].data(), msg[2].size()); - - try - { - std::string value = get_param_(module, parameter); - zmq::message_t *pMsg = new zmq::message_t(value.size()); - memcpy ((void*) pMsg->data(), value.data(), value.size()); - repSocket.send(*pMsg, 0); - delete pMsg; - } - catch (ParameterError &err) - { - send_fail_reply(&repSocket, err.what()); - } - } - else if (msg.size() == 4 && command == "set") - { - std::string module((char*) msg[1].data(), msg[1].size()); - std::string parameter((char*) msg[2].data(), msg[2].size()); - std::string value((char*) msg[3].data(), msg[3].size()); - - try - { - set_param_(module, parameter, value); - send_ok_reply(&repSocket); - } - catch (ParameterError &err) - { - send_fail_reply(&repSocket, err.what()); - } - } - else - send_fail_reply(&repSocket, "Unsupported command"); - } - - // check if thread is interrupted - boost::this_thread::interruption_point(); - } - } - catch (boost::thread_interrupted&) {} - catch (zmq::error_t &e) - { - std::cerr << "ZMQ error: " << std::string(e.what()) << std::endl; - } + // create zmq reply socket for receiving ctrl parameters + zmq::socket_t repSocket(m_zmqContext, ZMQ_REP); + std::cout << "Starting zmq remote control thread" << std::endl; + try + { + // connect the socket + int hwm = 100; + int linger = 0; + repSocket.setsockopt(ZMQ_RCVHWM, &hwm, sizeof(hwm)); + repSocket.setsockopt(ZMQ_SNDHWM, &hwm, sizeof(hwm)); + repSocket.setsockopt(ZMQ_LINGER, &linger, sizeof(linger)); + repSocket.bind(m_endpoint.c_str()); + + // create pollitem that polls the ZMQ sockets + zmq::pollitem_t pollItems[] = { {repSocket, 0, ZMQ_POLLIN, 0} }; + for(;;) + { + zmq::poll(pollItems, 1, 100); + std::vector msg; + if (pollItems[0].revents & ZMQ_POLLIN) + { + recv_all(&repSocket, msg); + std::string command((char*)msg[0].data(), msg[0].size()); + + if (msg.size() == 1 && command == "ping") + { + send_ok_reply(&repSocket); + } + else if (msg.size() == 3 && command == "get") + { + std::string module((char*) msg[1].data(), msg[1].size()); + std::string parameter((char*) msg[2].data(), msg[2].size()); + + try + { + std::string value = get_param_(module, parameter); + zmq::message_t *pMsg = new zmq::message_t(value.size()); + memcpy ((void*) pMsg->data(), value.data(), value.size()); + repSocket.send(*pMsg, 0); + delete pMsg; + } + catch (ParameterError &err) + { + send_fail_reply(&repSocket, err.what()); + } + } + else if (msg.size() == 4 && command == "set") + { + std::string module((char*) msg[1].data(), msg[1].size()); + std::string parameter((char*) msg[2].data(), msg[2].size()); + std::string value((char*) msg[3].data(), msg[3].size()); + + try + { + set_param_(module, parameter, value); + send_ok_reply(&repSocket); + } + catch (ParameterError &err) + { + send_fail_reply(&repSocket, err.what()); + } + } + else + send_fail_reply(&repSocket, "Unsupported command"); + } + + // check if thread is interrupted + boost::this_thread::interruption_point(); + } + } + catch (boost::thread_interrupted&) {} + catch (zmq::error_t &e) + { + std::cerr << "ZMQ error: " << std::string(e.what()) << std::endl; + } catch (std::exception& e) { std::cerr << "Remote control caught exception: " << e.what() << std::endl; m_fault = true; } - repSocket.close(); + repSocket.close(); } #endif + diff --git a/src/RemoteControl.h b/src/RemoteControl.h index 7c830b2..905e153 100644 --- a/src/RemoteControl.h +++ b/src/RemoteControl.h @@ -93,40 +93,37 @@ class BaseRemoteController { virtual ~BaseRemoteController() {} }; -class RemoteControllers { /* Holds all our remote controllers, i.e. we may have more than * one type of controller running. -*/ + */ +class RemoteControllers { public: - RemoteControllers() {} - virtual ~RemoteControllers() {} - - void add_controller(BaseRemoteController *rc) { - m_controllers.push_back(rc); - } + void add_controller(BaseRemoteController *rc) { + m_controllers.push_back(rc); + } - void add_controllable(RemoteControllable *rc) { + void add_controllable(RemoteControllable *rc) { for (std::list::iterator it = m_controllers.begin(); it != m_controllers.end(); ++it) { - (*it)->enrol(rc); - } - } - + (*it)->enrol(rc); + } + } + void check_faults() { for (std::list::iterator it = m_controllers.begin(); it != m_controllers.end(); ++it) { - if ((*it)->fault_detected()) - { - fprintf(stderr, - "Detected Remote Control fault, restarting it\n"); - (*it)->restart(); - } - } - } - size_t get_no_controllers() { return m_controllers.size(); } - - private: - std::list m_controllers; + if ((*it)->fault_detected()) + { + fprintf(stderr, + "Detected Remote Control fault, restarting it\n"); + (*it)->restart(); + } + } + } + size_t get_no_controllers() { return m_controllers.size(); } + + private: + std::list m_controllers; }; /* Objects that support remote control must implement the following class */ @@ -306,15 +303,14 @@ class RemoteControllerZmq : public BaseRemoteController { public: RemoteControllerZmq() : m_running(false), m_fault(false), - m_zmqContext(1), + m_zmqContext(1), m_endpoint("") { } RemoteControllerZmq(std::string endpoint) : m_running(true), m_fault(false), m_child_thread(&RemoteControllerZmq::process, this), - m_zmqContext(1), - m_endpoint(endpoint) - { } + m_zmqContext(1), + m_endpoint(endpoint) { } ~RemoteControllerZmq() { m_running = false; @@ -336,9 +332,9 @@ class RemoteControllerZmq : public BaseRemoteController { private: void restart_thread(); - void recv_all(zmq::socket_t* pSocket, std::vector &message); - void send_ok_reply(zmq::socket_t *pSocket); - void send_fail_reply(zmq::socket_t *pSocket, const std::string &error); + void recv_all(zmq::socket_t* pSocket, std::vector &message); + void send_ok_reply(zmq::socket_t *pSocket); + void send_fail_reply(zmq::socket_t *pSocket, const std::string &error); void process(); @@ -377,8 +373,8 @@ class RemoteControllerZmq : public BaseRemoteController { /* This controller commands the controllables in the cohort */ std::list m_cohort; - zmq::context_t m_zmqContext; - std::string m_endpoint; + zmq::context_t m_zmqContext; + std::string m_endpoint; }; #endif -- cgit v1.2.3 From 2e646a26c9db66dd5776667d9c9b73d798f5ffda Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 23 Jan 2015 10:46:26 +0100 Subject: Merge input-zeromq and output-zeromq configure options --- INSTALL | 7 ++++--- configure.ac | 19 ++++++------------- src/DabMod.cpp | 17 +++++++---------- src/InputReader.h | 4 ++-- src/InputZeroMQReader.cpp | 2 +- src/OutputZeroMQ.cpp | 4 ++-- src/OutputZeroMQ.h | 4 ++-- src/RemoteControl.cpp | 2 +- src/RemoteControl.h | 4 ++-- 9 files changed, 27 insertions(+), 36 deletions(-) (limited to 'src/RemoteControl.h') diff --git a/INSTALL b/INSTALL index 55385ba..bb14565 100644 --- a/INSTALL +++ b/INSTALL @@ -2,8 +2,8 @@ Required dependencies: ====================== * Boost 1.41 or later + * Optional UHD for USRP * Optional ZeroMQ http://www.zeromq.org - Use --disable-input-zeromq if you don't have it * Optional FFTW 3.x (included KISS FFT is used as fallback) Simple install procedure: @@ -11,7 +11,7 @@ Simple install procedure: % tar xjf odr-dabmod-X.Y.Z.tar.bz2 # Unpack the source % cd odr-dabmod-X.Y.Z # Change to the source directory - % ./configure --disable-debug --with-debug-malloc=yes + % ./configure --enable-zeromq --enable-output-uhd # Run the configure script % make # Build ODR-DabMod [ as root ] @@ -21,7 +21,8 @@ Configure options ================= The configure script can be launch with a variety of options: - --enable-input-zeromq Enable ZeroMQ input (to be used with ODR-DabMux) + --enable-zeromq Enable ZeroMQ input (to be used with ODR-DabMux), + output and remotecontrol. --enable-output-uhd Includes the binding to the UHD driver for USRPs You have the choice between two FFT libraries: KISS FFT and FFTW. KISS FFT is a diff --git a/configure.ac b/configure.ac index 615bf6d..739f54a 100644 --- a/configure.ac +++ b/configure.ac @@ -71,12 +71,8 @@ AC_ARG_ENABLE([kiss_fft], [], [enable_kiss=no]) # ZeroMQ message queue input -AC_ARG_ENABLE([input_zeromq], - AS_HELP_STRING([--enable-input-zeromq], [Enable ZeroMQ input])) - -# ZeroMQ message IQ output -AC_ARG_ENABLE([output_zeromq], - AS_HELP_STRING([--enable-output-zeromq], [Enable ZeroMQ output])) +AC_ARG_ENABLE([zeromq], + AS_HELP_STRING([--enable-zeromq], [Enable ZeroMQ input, output and remote control])) # UHD support control AC_ARG_ENABLE([output_uhd], @@ -91,13 +87,10 @@ AS_IF([test "x$enable_fftw" = "xyes"], AC_MSG_NOTICE([Found FFTW3]), AC_MSG_NOTICE([Using Kiss FFT]) ) -echo "Checking input zeromq" +echo "Checking zeromq" -AS_IF([test "x$enable_input_zeromq" = "xyes"], - [AC_DEFINE(HAVE_INPUT_ZEROMQ, [1], [Define if ZeroMQ input is enabled]) , - AC_CHECK_LIB(zmq, zmq_init, ZMQ_LIBS="-lzmq" ,[AC_MSG_ERROR([ZeroMQ libzmq is required])])]) -AS_IF([test "x$enable_output_zeromq" = "xyes"], - [AC_DEFINE(HAVE_OUTPUT_ZEROMQ, [1], [Define if ZeroMQ output is enabled]) , +AS_IF([test "x$enable_zeromq" = "xyes"], + [AC_DEFINE(HAVE_ZEROMQ, [1], [Define if ZeroMQ is enabled]) , AC_CHECK_LIB(zmq, zmq_init, ZMQ_LIBS="-lzmq" ,[AC_MSG_ERROR([ZeroMQ libzmq is required])])]) AS_IF([test "x$enable_debug" = "xno"], [OPTIM="-O2" DEBUG="" EXTRA="$EXTRA -DNDEBUG"], @@ -203,7 +196,7 @@ echo "***********************************************" echo enabled="" disabled="" -for feat in debug prof trace fftw fft_simd output_uhd input_zeromq output_zeromq +for feat in debug prof trace fftw fft_simd output_uhd zeromq do eval var=\$enable_$feat AS_IF([test "x$var" = "xyes"], diff --git a/src/DabMod.cpp b/src/DabMod.cpp index 4912bee..cc7dd96 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -213,7 +213,7 @@ int main(int argc, char* argv[]) Logger logger; InputFileReader inputFileReader(logger); -#if defined(HAVE_INPUT_ZEROMQ) +#if defined(HAVE_ZEROMQ) InputZeroMQReader inputZeroMQReader(logger); #endif InputReader* inputReader; @@ -352,14 +352,11 @@ int main(int argc, char* argv[]) "\n"; std::cerr << "Compiled with features: " << -#if defined(HAVE_INPUT_ZEROMQ) - "input_zeromq " << +#if defined(HAVE_ZEROMQ) + "zeromq " << #endif #if defined(HAVE_OUTPUT_UHD) "output_uhd " << -#endif -#if defined(HAVE_OUTPUT_ZEROMQ) - "output_zeromq " << #endif "\n"; @@ -408,7 +405,7 @@ int main(int argc, char* argv[]) } } -#if defined(HAVE_INPUT_ZEROMQ) +#if defined(HAVE_ZEROMQ) if (pt.get("remotecontrol.zmqctrl", 0) == 1) { try { std::string zmqCtrlEndpoint = pt.get("remotecontrol.zmqctrlendpoint", ""); @@ -592,7 +589,7 @@ int main(int argc, char* argv[]) useUHDOutput = 1; } #endif -#if defined(HAVE_OUTPUT_ZEROMQ) +#if defined(HAVE_ZEROMQ) else if (output_selected == "zmq") { outputName = pt.get("zmqoutput.listen"); useZeroMQOutput = 1; @@ -735,7 +732,7 @@ int main(int argc, char* argv[]) inputReader = &inputFileReader; } else if (inputTransport == "zeromq") { -#if !defined(HAVE_INPUT_ZEROMQ) +#if !defined(HAVE_ZEROMQ) fprintf(stderr, "Error, ZeroMQ input transport selected, but not compiled in!\n"); ret = -1; goto END_MAIN; @@ -786,7 +783,7 @@ int main(int argc, char* argv[]) } } #endif -#if defined(HAVE_OUTPUT_ZEROMQ) +#if defined(HAVE_ZEROMQ) else if (useZeroMQOutput) { /* We normalise the same way as for the UHD output */ normalise = 1.0f/50000.0f; diff --git a/src/InputReader.h b/src/InputReader.h index 164c5ac..3e0dcab 100644 --- a/src/InputReader.h +++ b/src/InputReader.h @@ -31,7 +31,7 @@ #endif #include -#if defined(HAVE_INPUT_ZEROMQ) +#if defined(HAVE_ZEROMQ) # include "zmq.hpp" # include "ThreadsafeQueue.h" #endif @@ -130,7 +130,7 @@ class InputFileReader : public InputReader // after 2**32 * 24ms ~= 3.3 years }; -#if defined(HAVE_INPUT_ZEROMQ) +#if defined(HAVE_ZEROMQ) /* A ZeroMQ input. See www.zeromq.org for more info */ struct InputZeroMQThreadData diff --git a/src/InputZeroMQReader.cpp b/src/InputZeroMQReader.cpp index cfb56b2..f7f5702 100644 --- a/src/InputZeroMQReader.cpp +++ b/src/InputZeroMQReader.cpp @@ -29,7 +29,7 @@ # include "config.h" #endif -#if defined(HAVE_INPUT_ZEROMQ) +#if defined(HAVE_ZEROMQ) #include #include diff --git a/src/OutputZeroMQ.cpp b/src/OutputZeroMQ.cpp index 0e759dd..793e473 100644 --- a/src/OutputZeroMQ.cpp +++ b/src/OutputZeroMQ.cpp @@ -30,7 +30,7 @@ #include #include -#if defined(HAVE_OUTPUT_ZEROMQ) +#if defined(HAVE_ZEROMQ) OutputZeroMQ::OutputZeroMQ(std::string endpoint, Buffer* dataOut) : ModOutput(ModFormat(1), ModFormat(0)), @@ -63,5 +63,5 @@ int OutputZeroMQ::process(Buffer* dataIn, Buffer* dataOut) return dataIn->getLength(); } -#endif // HAVE_OUTPUT_ZEROMQ_H +#endif // HAVE_ZEROMQ diff --git a/src/OutputZeroMQ.h b/src/OutputZeroMQ.h index 1c48fe7..a80eab4 100644 --- a/src/OutputZeroMQ.h +++ b/src/OutputZeroMQ.h @@ -31,7 +31,7 @@ # include "config.h" #endif -#if defined(HAVE_OUTPUT_ZEROMQ) +#if defined(HAVE_ZEROMQ) #include "ModOutput.h" #include "zmq.hpp" @@ -54,7 +54,7 @@ class OutputZeroMQ : public ModOutput std::string m_name; }; -#endif // HAVE_OUTPUT_ZEROMQ_H +#endif // HAVE_ZEROMQ #endif // OUTPUT_ZEROMQ_H diff --git a/src/RemoteControl.cpp b/src/RemoteControl.cpp index 1e8dda5..65da3b7 100644 --- a/src/RemoteControl.cpp +++ b/src/RemoteControl.cpp @@ -248,7 +248,7 @@ void RemoteControllerTelnet::reply(tcp::socket& socket, string message) } -#if defined(HAVE_INPUT_ZEROMQ) +#if defined(HAVE_ZEROMQ) void RemoteControllerZmq::restart() { diff --git a/src/RemoteControl.h b/src/RemoteControl.h index 905e153..89a1583 100644 --- a/src/RemoteControl.h +++ b/src/RemoteControl.h @@ -33,7 +33,7 @@ # include "config.h" #endif -#if defined(HAVE_INPUT_ZEROMQ) +#if defined(HAVE_ZEROMQ) #include #endif @@ -295,7 +295,7 @@ class RemoteControllerTelnet : public BaseRemoteController { int m_port; }; -#if defined(HAVE_INPUT_ZEROMQ) +#if defined(HAVE_ZEROMQ) /* Implements a Remote controller using zmq transportlayer * that listens on localhost */ -- cgit v1.2.3