From ea15e4e4417d24d3bbcec120dc5c7d796898f5b0 Mon Sep 17 00:00:00 2001 From: Andy Wood Date: Mon, 12 Feb 2024 15:41:51 +0000 Subject: [PATCH] Process zmq connection while resetting to ensure first line is displayed --- ui/driver/driver_pi.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ui/driver/driver_pi.py b/ui/driver/driver_pi.py index 0d2ee43..885618d 100644 --- a/ui/driver/driver_pi.py +++ b/ui/driver/driver_pi.py @@ -163,13 +163,14 @@ def send_data(self, cmd, data=[]): self.HDLC.sendFrame(payload) + if cmd == comms.CMD_RESET and not hasattr(self, 'context'): + # defer this 'til after the initial reset is sent as it slows startup + import zmq + self.context = zmq.Context() + self.socket = self.context.socket(zmq.PUB) + self.socket.bind('tcp://*:%s' % LINE_PUBLISHING_PORT) + def _publish_line(self, row, content): - if not hasattr(self, 'context'): - # defer this 'til needed as it slows startup - import zmq - self.context = zmq.Context() - self.socket = self.context.socket(zmq.PUB) - self.socket.bind('tcp://*:%s' % LINE_PUBLISHING_PORT) brl = ''.join([braille.pin_num_to_unicode(ch) for ch in content]) brf = ''.join(braille.pin_nums_to_alphas(content)) self.socket.send_pyobj(