Signed-off-by: Ebbe Baß <ebbe.bass>
main
Ebbe Baß 2024-02-15 12:28:14 +01:00
parent 8264d6aa52
commit f8770edc27
2 changed files with 9 additions and 30 deletions

View File

@ -113,8 +113,6 @@ def start_mqtt_publishers():
mqtt_client = connect_mqtt() mqtt_client = connect_mqtt()
artnetBindIp = get_eth0_ip() artnetBindIp = get_eth0_ip()
artNet = Artnet.Artnet(BINDIP = artnetBindIp, DEBUG = True, SHORTNAME = "PiXelTubeMaster", LONGNAME = "PiXelTubeMaster", PORT = 6454) artNet = Artnet.Artnet(BINDIP = artnetBindIp, DEBUG = True, SHORTNAME = "PiXelTubeMaster", LONGNAME = "PiXelTubeMaster", PORT = 6454)
tuple_ip = (str(get_eth0_ip()), 6454)
artNet.art_pol_reply(tuple_ip)
try: try:
while True: while True:
try: try:

View File

@ -3,40 +3,21 @@ import sys
import python_artnet as Artnet import python_artnet as Artnet
import os import os
def get_eth0_ip(): artnet = Artnet.Artnet()
try:
# Get the IP address of the eth0 interface
eth0_ip = str(os.system("ip -4 -o addr show eth0 | awk '{print $4}' | cut -d '/' -f 1 "))
return eth0_ip
except (KeyError, IndexError, OSError) as e:
print(f"Error getting eth0 IP: {e}")
exit
### ArtNet Config ###
artnetBindIp = get_eth0_ip()
### Art-Net Setup ###
# Sets debug in Art-Net module.
# Creates Artnet socket on the selected IP and Port
artNet = Artnet.Artnet(BINDIP = artnetBindIp, DEBUG = False, SHORTNAME = "PiXelTubeMaster", LONGNAME = "PiXelTubeMaster", PORT = 6454)
tuple_ip = (str(get_eth0_ip()), 6454)
# artNet.art_pol_reply(tuple_ip)
while True: while True:
try: try:
# Gets whatever the last Art-Net packet we received is
artNetPacket = artNet.readPacket() artNetPacket = artnet.readPacket()
# Make sure we actually *have* a packet
if artNetPacket is not None and artNetPacket.data is not None: if artNetPacket is not None and artNetPacket.data is not None:
if artNetPacket.universe == 0: if artNetPacket.universe == 0:
print("YES") print("Universe was the specified universe: "+str(artNetPacket.universe))
else: else:
print("Universe: "+str(artNetPacket.universe)) print("Universe was not the specified: "+str(artNetPacket.universe))
# Stores the packet data array else:
# dmxPacket = artNetPacket.data print("Packet was none")
except KeyboardInterrupt: except KeyboardInterrupt:
artnet.close()
break break
time.sleep(0.01)
# Close the various connections cleanly so nothing explodes :)
artNet.close()
sys.exit()