From 8dd4924f1384e0667bfc0d46389903df94f94dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebbe=20Ba=C3=9F?= Date: Wed, 14 Feb 2024 21:27:51 +0100 Subject: [PATCH] added more tries and a for loop for the universe_list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ebbe Baß --- server/app.py | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/server/app.py b/server/app.py index 3639c22..ed9b926 100644 --- a/server/app.py +++ b/server/app.py @@ -123,21 +123,27 @@ def start_mqtt_publishers(universe_count): try: while True: try: - # Gets whatever the last Art-Net packet we received is - artNetPacket = artNet.readPacket() - # Make sure we actually *have* a packet - if artNetPacket is not None and artNetPacket.data is not None: - #Checks to see if the current packet is for the specified DMX Universe - if artNetPacket.universe in universe_list: - print(artNetPacket.universe) - dmxPacket = artNetPacket.data - for i in range(512): - # Create MQTT topic based on the universe and channel - topic = f"{str(artNetPacket.universe)}/{str(i)}" - - # Publish the DMX value to the MQTT topic - mqtt_client.publish(topic, str(dmxPacket[i-1])) - + for universe in universe_list: + # Gets whatever the last Art-Net packet we received is + artNetPacket = artNet.readPacket() + # Make sure we actually *have* a packet + if artNetPacket is not None and artNetPacket.data is not None: + #Checks to see if the current packet is for the specified DMX Universe + if artNetPacket.universe == universe: + print(artNetPacket.universe) + dmxPacket = artNetPacket.data + try: + for i in range(512): + # Create MQTT topic based on the universe and channel + topic = f"{str(artNetPacket.universe)}/{str(i)}" + + # Publish the DMX value to the MQTT topic + mqtt_client.publish(topic, str(dmxPacket[i-1])) + except Exception as e: + print(f"Error in universes {universe_list}: {e}") + except KeyboardInterrupt: + break + except Exception as e: print(f"Error in universes {universe_list}: {e}") except KeyboardInterrupt: