sciencegey / python_artnet

Easy-to-use python receiver for artnet
MIT License
3 stars 0 forks source link

when using .readPacket(), .artnet_packet_to_array only returns highest active universe #3

Closed ping-mee closed 3 months ago

ping-mee commented 6 months ago

Steps to recreate this problem:

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

debug = False

You can choose between setting your own IP or if you run this on a Pi getting a IP automatically form eth0

artnetBindIp = str(get_eth0_ip())

artnetBindIp = "10.0.0.4"

artnetUniverse = 0

Art-Net Setup

Creates Artnet socket on the selected IP and Port

artNet = Artnet.Artnet(artnetBindIp, DEBUG=debug)

while True: try:

Read latest ArtNet packet

    artNetPacket = artNet.readPacket()
    # Print out the universe of said packet
    print("My univ: "+str(artNetPacket.universe))

# Big red stop button just in case
except KeyboardInterrupt:
    break
# Give me that exceptions
except Exception as e:
    print(e)
# Slow down there young fella
time.sleep(0.1)

Bro, close dat shit! It is over for today! No more Mario Kart 8 Deluxe

artNet.close() sys.exit()



Result:
Run that script and you will only get printed out every universe starting from 2 (be aware that actually this is universe 3 since ArtNet universes start counting at 0).

Solution:
I don't really have a solution but I have a hint.
In the python_artnet.py module script on line 180 I put a `print(packet.universe)` and every universe starting from 0 got printed out.
Maybe there is an issue when making the packets to arrays but idk about that.
sciencegey commented 6 months ago

Thanks for raising the issue :)

The project I originally made the library for only cared about 1 universe, so I never checked if it would work with more than one :V

Basically, as the moment it just spits out the last packet it received, which isn't useful if you want to receive multiple universes (because you're going to get random one each time), but does work if you only receive 1 universe.

Sooo, I'll have to "rework" it so that it will either store multiple packets (one for each universe), or have multiple "listeners" (one for each universe); but I'll have to figure that out :)))))

ping-mee commented 6 months ago

Thanks you sooooooo much for awnsering so quickly. Because this is such a niche topic, I already was so thankfull that some had developed this module. So thank you for responding so quickly.

I am currently working on a little fun project. I am going to mention your help with the bug fix in my README :)