Skip to content

Commit

Permalink
Merge pull request #1319 from anarkiwi/comments
Browse files Browse the repository at this point in the history
explain need for grpduzmq
  • Loading branch information
anarkiwi authored Jun 23, 2024
2 parents a53b6cb + 327d8a7 commit d83f9f6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion gamutrf/grpduzmq.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import logging
import sys
import pmt
import zmq
Expand All @@ -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,
Expand All @@ -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))

0 comments on commit d83f9f6

Please sign in to comment.