From 327d8a78ff1c7c35f5b3820f8ceb2c2bdb292fc5 Mon Sep 17 00:00:00 2001 From: Josh Bailey Date: Sun, 23 Jun 2024 22:11:29 +0000 Subject: [PATCH] explain need for grpduzmq --- gamutrf/grpduzmq.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gamutrf/grpduzmq.py b/gamutrf/grpduzmq.py index ccba9997..1eeb7ee2 100644 --- a/gamutrf/grpduzmq.py +++ b/gamutrf/grpduzmq.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +import logging import sys import pmt import zmq @@ -16,6 +17,9 @@ DELIM = "\n" +# It would be ideal to just use gnuradio's https://github.com/gnuradio/gnuradio/blob/main/gr-zeromq/lib/pub_msg_sink_impl.cc +# block. Unfortunately, this block calls pmt::serialize(), but we just want to send simple json strings. That means +# a receiver client would need to run pmt::deserialize() which requires an installation of gnuradio. class pduzmq(gr.basic_block): def __init__( self, @@ -40,4 +44,7 @@ def stop(self): def receive_pdu(self, pdu): item = pmt.to_python(pmt.cdr(pdu)).tobytes().decode("utf8").strip() - self.zmq_pub.send_string(item + DELIM, flags=zmq.NOBLOCK) + try: + self.zmq_pub.send_string(item + DELIM, flags=zmq.NOBLOCK) + except zmq.ZMQError as e: + logging.error(str(e))