Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

explain need for grpduzmq #1319

Merged
merged 1 commit into from
Jun 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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))

Check warning on line 50 in gamutrf/grpduzmq.py

View check run for this annotation

Codecov / codecov/patch

gamutrf/grpduzmq.py#L47-L50

Added lines #L47 - L50 were not covered by tests
Loading