From b1b480da080d04bf4051a383dd9916a3262f0674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebbe=20Ba=C3=9F?= Date: Wed, 14 Feb 2024 22:06:14 +0100 Subject: [PATCH] just removed the dumbest mechanism ever. WHY CHECK IF UNIVERSE IS IN LIST IF ALL THE USED UNIVERSES ARE GETTING SENDT TO ME SO I ONLY HAVE TO UPDATE AND PUBLISH MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ebbe Baß --- server/app.py | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/server/app.py b/server/app.py index cba4681..bcadd37 100644 --- a/server/app.py +++ b/server/app.py @@ -112,38 +112,34 @@ def connect_mqtt(): return client def start_mqtt_publishers(universe_count): - universe_list = list(range(universe_count)) # Create and start a thread for each universe mqtt_client = connect_mqtt() artnetBindIp = get_eth0_ip() artNet = Artnet.Artnet(BINDIP = artnetBindIp, DEBUG = False, SHORTNAME = "PiXelTubeMaster", LONGNAME = "PiXelTubeMaster", PORT = 6454, REFRESH=30) tuple_ip = (str(get_eth0_ip()), 6454) artNet.art_pol_reply(tuple_ip) - print(universe_list) try: while True: try: # for universe in range(universe_count): - # universe = universe - 1 # 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 range(universe_count): - 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 + 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 {str(artNetPacket.universe)}: {e}") + except KeyboardInterrupt: + break except Exception as e: print(f"Error in universes {universe_list}: {e}")