From 49d051042c7385b862bafa75b83abd991a90a15c Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 10 Mar 2025 07:47:25 +0000 Subject: [PATCH] add logging to the UDP broadcast discovery path --- saturn_printer.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/saturn_printer.py b/saturn_printer.py index 7a509d9..abdbce7 100644 --- a/saturn_printer.py +++ b/saturn_printer.py @@ -72,6 +72,7 @@ class SaturnPrinter: with sock: sock.settimeout(timeout) sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, timeout) + logging.debug(f"sending M99999 to {broadcast}:{SATURN_UDP_PORT}") sock.sendto(b'M99999', (broadcast, SATURN_UDP_PORT)) now = time.time() @@ -85,6 +86,7 @@ class SaturnPrinter: else: #logging.debug(f'Found printer at {addr}') pdata = json.loads(data.decode('utf-8')) + logging.debug(f"received: {pdata}") printers.append(SaturnPrinter(addr, pdata)) return printers @@ -101,6 +103,7 @@ class SaturnPrinter: sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) with sock: sock.settimeout(timeout) + logging.debug(f"sending M99999 to {broadcast}:{SATURN_UDP_PORT}") sock.sendto(b'M99999', (self.addr, SATURN_UDP_PORT)) try: data, addr = sock.recvfrom(1024) @@ -108,6 +111,7 @@ class SaturnPrinter: return False else: pdata = json.loads(data.decode('utf-8')) + logging.debug(f"received: {pdata}") self.set_desc(pdata) def set_desc(self, desc): @@ -127,6 +131,7 @@ class SaturnPrinter: # Tell the printer to connect sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) with sock: + logging.debug(f"sending M66666 to {self.addr}") sock.sendto(b'M66666 ' + str(mqtt.port).encode('utf-8'), self.addr) # wait for the connection