From 188df90a11b2765cd0df4b90692cab24b8de4811 Mon Sep 17 00:00:00 2001 From: RT Date: Sun, 14 Mar 2021 15:31:09 +0200 Subject: [PATCH 1/2] Allow broadcast in x.x.x.255 --- lib/StupidArtnet.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/StupidArtnet.py b/lib/StupidArtnet.py index c26ae22..8fa69b2 100644 --- a/lib/StupidArtnet.py +++ b/lib/StupidArtnet.py @@ -18,7 +18,7 @@ class StupidArtnet(): UDP_PORT = 6454 - def __init__(self, targetIP='127.0.0.1', universe=0, packet_size=512, fps=30, receiver_needs_even_packet_size=True): + def __init__(self, targetIP='127.0.0.1', universe=0, packet_size=512, fps=30, receiver_needs_even_packet_size=True, broadcast=False): """Class Initialization.""" # Instance variables self.TARGET_IP = targetIP @@ -38,6 +38,9 @@ def __init__(self, targetIP='127.0.0.1', universe=0, packet_size=512, fps=30, re # UDP SOCKET self.s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + if broadcast: + self.s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) + # Timer self.fps = fps From 8160308d29c808792723e709d20536a09aa173d6 Mon Sep 17 00:00:00 2001 From: cv <34649812+cpvalente@users.noreply.github.com> Date: Sat, 15 May 2021 21:21:24 +0200 Subject: [PATCH 2/2] docs: clarify init --- example.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/example.py b/example.py index ce7ad14..d6ffbcd 100644 --- a/example.py +++ b/example.py @@ -3,9 +3,9 @@ import random # THESE ARE MOST LIKELY THE VALUES YOU WILL BE NEEDING -target_ip = '192.168.1.10' # typically in 2.x or 10.x range -universe = 0 # see docs -packet_size = 100 # it is not necessary to send whole universe +target_ip = '255.255.255.255' # typically in 2.x or 10.x range +universe = 0 # see docs +packet_size = 100 # it is not necessary to send whole universe # CREATING A STUPID ARTNET OBJECT # SETUP NEEDS A FEW ELEMENTS @@ -13,7 +13,8 @@ # UNIVERSE = DEFAULT 0 # PACKET_SIZE = DEFAULT 512 # FRAME_RATE = DEFAULT 30 -a = StupidArtnet(target_ip, universe, packet_size) +# ISBROADCAST = DEFAULT FALSE +a = StupidArtnet(target_ip, universe, packet_size, 30, True, True) # MORE ADVANCED CAN BE SET WITH SETTERS IF NEEDED # NET = DEFAULT 0