From 9c01b98542f3297bbd898f3e2ed3ff9424d98c1f Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 6 Jun 2018 21:46:05 -0400 Subject: [PATCH] configuration updates --- op25/gr-op25_repeater/apps/http.py | 18 ++++++++++++++++-- op25/gr-op25_repeater/apps/terminal.py | 9 +++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/op25/gr-op25_repeater/apps/http.py b/op25/gr-op25_repeater/apps/http.py index b0f00ad..1352daf 100755 --- a/op25/gr-op25_repeater/apps/http.py +++ b/op25/gr-op25_repeater/apps/http.py @@ -269,6 +269,14 @@ class Backend(threading.Thread): self.subproc = None self.backend = '%s/%s' % (os.getcwd(), 'rx.py') + self.q_watcher = queue_watcher(self.input_q, self.process_msg) + + def publish(self, msg): + t = msg.type() + s = msg.to_string() + a = msg.arg1() + self.zmq_pub.send(json.dumps({'command': s, 'data': a, 'msgtype': t})) + def check_subproc(self): # return True if subprocess is active if not self.subproc: return False @@ -335,8 +343,12 @@ class Backend(threading.Thread): def run(self): while self.keep_running: - msg = self.input_q.delete_head() - self.process_msg(msg) + js = self.zmq_sub.recv() + if not self.keep_running: + break + msg = gr.message().make_from_string(js, -4, 0, 0) + if not self.output_q.full_p(): + self.output_q.insert_tail(msg) class rx_options(object): def __init__(self, name): @@ -389,6 +401,8 @@ def http_main(): my_backend = Backend(options, backend_input_q, backend_output_q) server = http_server(input_q, output_q, options.endpoint) + q_watcher = queue_watcher(output_q, lambda msg : my_backend.publish(msg)) + backend_q_watcher = queue_watcher(backend_output_q, lambda msg : process_qmsg(msg)) server.run() diff --git a/op25/gr-op25_repeater/apps/terminal.py b/op25/gr-op25_repeater/apps/terminal.py index cbc0114..51c5ceb 100755 --- a/op25/gr-op25_repeater/apps/terminal.py +++ b/op25/gr-op25_repeater/apps/terminal.py @@ -233,22 +233,19 @@ class zeromq_terminal(threading.Thread): self.zmq_pub.sndhwm = 5 self.zmq_pub.bind('tcp://*:%d' % port) - self.queue_watcher = q_watcher(self.input_q, self.process_qmsg) + self.queue_watcher = q_watcher(self.input_q, lambda msg : self.zmq_pub.send(msg.to_string())) self.start() def end_terminal(self): self.keep_running = False - def process_qmsg(self, msg): - msg = self.input_q.delete_head() - self.zmq_pub.send(msg.to_string()) - def run(self): while self.keep_running: js = self.zmq_sub.recv() if not self.keep_running: break - msg = gr.message().make_from_string(js, -4, 0, 0) + d = json.loads(js) + msg = gr.message().make_from_string(str(d['command']), d['msgtype'], d['data'], 0) if self.output_q.full_p(): self.output_q.delete_head() if not self.output_q.full_p():