diff --git a/server/app.py b/server/app.py index 84e1986..adf08d8 100644 --- a/server/app.py +++ b/server/app.py @@ -7,6 +7,7 @@ import python_artnet as Artnet import os from getmac import get_mac_address import time +import sys app = Flask(__name__) @@ -137,7 +138,8 @@ def start_mqtt_publishers(): except Exception as e: print(e) except KeyboardInterrupt: - break + artNet.close() + sys.exit() except Exception as e: print(e) diff --git a/server/exampleReceiver.py b/server/exampleReceiver.py index dd8e2c5..6dbd804 100644 --- a/server/exampleReceiver.py +++ b/server/exampleReceiver.py @@ -23,18 +23,18 @@ tuple_ip = (str(get_eth0_ip()), 6454) artNet.art_pol_reply(tuple_ip) artNetPacket = artNet.readPacket() print(type(artNetPacket.universe)) -# 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: -# print("Universe: "+str(artNetPacket.universe)) -# # Stores the packet data array -# dmxPacket = artNetPacket.data +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: + print("Universe: "+str(artNetPacket.universe)) + # Stores the packet data array + dmxPacket = artNetPacket.data -# except KeyboardInterrupt: -# break + except KeyboardInterrupt: + break # Close the various connections cleanly so nothing explodes :) artNet.close()