2024-02-13 13:08:23 +00:00
|
|
|
import time
|
|
|
|
import sys
|
|
|
|
import python_artnet as Artnet
|
2024-02-13 17:43:38 +00:00
|
|
|
import os
|
2024-02-13 13:08:23 +00:00
|
|
|
|
2024-02-15 11:31:37 +00:00
|
|
|
def get_eth0_ip():
|
|
|
|
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
|
2024-02-13 13:08:23 +00:00
|
|
|
|
2024-02-15 22:41:52 +00:00
|
|
|
debug = False
|
2024-02-15 20:14:25 +00:00
|
|
|
|
2024-02-15 22:38:23 +00:00
|
|
|
### ArtNet Config ###
|
2024-02-15 23:11:37 +00:00
|
|
|
# artnetBindIp = str(get_eth0_ip())
|
|
|
|
artnetBindIp = "10.0.0.4"
|
2024-02-15 22:38:23 +00:00
|
|
|
artnetUniverse = 0
|
|
|
|
|
|
|
|
### Art-Net Setup ###
|
|
|
|
# Sets debug in Art-Net module.
|
|
|
|
# Creates Artnet socket on the selected IP and Port
|
|
|
|
artNet = Artnet.Artnet(artnetBindIp, DEBUG=debug)
|
2024-02-15 11:32:15 +00:00
|
|
|
|
2024-02-15 10:40:55 +00:00
|
|
|
while True:
|
|
|
|
try:
|
2024-02-15 22:38:23 +00:00
|
|
|
# Gets whatever the last Art-Net packet we received is
|
|
|
|
artNetPacket = artNet.readPacket()
|
|
|
|
# Make sure we actually *have* a packet
|
2024-02-15 10:40:55 +00:00
|
|
|
if artNetPacket is not None and artNetPacket.data is not None:
|
2024-02-15 22:38:23 +00:00
|
|
|
# Checks to see if the current packet is for the specified DMX Universe
|
|
|
|
if artNetPacket.universe == artnetUniverse:
|
|
|
|
print("Received specified universe: "+str(artNetPacket.universe))
|
|
|
|
|
|
|
|
# Print a newline so things look nice :)
|
2024-02-15 10:58:46 +00:00
|
|
|
else:
|
2024-02-15 22:38:23 +00:00
|
|
|
print("Did not receive specified universe. The received universe was universe: "+str(artNetPacket.universe))
|
|
|
|
|
2024-02-15 10:40:55 +00:00
|
|
|
except KeyboardInterrupt:
|
|
|
|
break
|
2024-02-15 22:38:23 +00:00
|
|
|
|
|
|
|
# Close the various connections cleanly so nothing explodes :)
|
|
|
|
artNet.close()
|
|
|
|
sys.exit()
|