I have a C++ code to send commands and change parameters in a GnuRadio flowgraph. To do a simple test I'm trying to send a string from a C++ code and visualize it in GnuRadio.This is my C++ code:
#include <zmq.hpp>#include <iostream>#include <string>int main() { // Create a ZeroMQ context and a REQ socket zmq::context_t context(1); zmq::socket_t socket(context, zmq::socket_type::req); socket.connect("tcp://127.0.0.1:55555"); // Ensure this matches GNU Radio's address std::string msg_content = "Hello World"; // Create a ZeroMQ message with the content zmq::message_t request(msg_content.size()); memcpy(request.data(), msg_content.c_str(), msg_content.size()); // Send the message to GNU Radio socket.send(request, zmq::send_flags::none); // Receive the reply from GNU Radio (required for REQ socket) zmq::message_t reply; socket.recv(reply); return 0;}
The GnuRadio is only 2 blocks: ZMQ REQ Message Source
connected to a Message Debug
block like the 2 blocks at the bottom of figure 1 here https://wiki.gnuradio.org/index.php/ZMQ_REP_Message_Sink
In ZMQ REQ Message Source
I set tcp://127.0.0.1:55555
I did a TCP dump to make sure my C++ sends something, and I can see the "Hello World" strings.
I also tried to send TCP messages directly from Ubuntu: echo "Hello, World!" | nc 127.0.0.1 55555
, and I still see them in the TCP dump, but still nothing in GR.
The only way I see the strings in GnuRadio is if I create another flowgraph with ZMQ REP Message Sink
sending to the first flowgraph