Giter VIP home page Giter VIP logo

python_artnet's Introduction

python_artnet

Easy-to-use and simple python receiver for Art-Net (that also implements device polling).

Installaton

All you need to do is clone the repository

$ git clone https://github.com/sciencegey/python_artnet.git
$ cd python_artnet
$ python3 samples/exampleReceiver.py

OR

Install using PIP

$ pip install python_artnet

Usage

All you need to do to start receiving data is import the module, start the listener, then check for received data whenever you want!

import python_artnet as Artnet

# By default it will listen on 0.0.0.0 (all interfaces)
artNet = Artnet.Artnet()

# Fetch the latest packet we received from universe 0.
artNetPacket = artNet.readBuffer()[0]
# And extract the DMX data from that packet.
dmxPacket = artNetPacket.data
# You'll also want to check that there *is* data in the packet;
# if there isn't then it returns None
# See the example for more information

# Close the listener nicely :)
artNet.close()

There are also plenty of arguments you can pass when you start the listener:

  • BINDIP - Which IP address you want to listen on (usually a broadcast address). This is the only one you really ever need to change. (Defaults to "" AKA 0.0.0.0 AKA all interfaces)
  • PORT - Which UDP port you want to listen on. Shouldn't need to ever change this. (Defaults to 6454)
The following are used for purely management purposes:
  • SYSIP - What the IP address of your system is. Purely cosmetic and only used to identify the system to ArtNet controllers. (Defaults to "10.10.10.1")
  • MAC - What the MAC address of your system is. Same as above. (Defaults to ["AA","BB","CC","DD","EE","FF"])
  • SWVER - What version of Art-Net we're using. In this case, V1.4 (Defaults to "14")
  • SHORTNAME and LONGNAME - Used to see what devices are what on a controller. (Shortname is truncated to 17 bytes long, longname is truncated to 63)
  • OEMCODE - What the Art-Net OEM code your device has. Only needs to be set if you have one. (In hex)
  • ESTACODE - What the ESTA Manafacturer Code your device has. Only needs to be set if you have one. (In hex)
  • PORTTYPE - Used to tell the controller what type of physical ports your device has. (Defaults to [0x80,0x00,0x00,0x00]) See the Art-Net documentation for more information
  • REFRESH - What the refresh rate (in Hz) of your device. (Defaults to 44 (the max for DMX))
  • DEBUG - Used to turn on debug output. (Defaults to False)

The artnet packet consists of the following:

  • ver - Which version of Art-Net the packet is using. Latest is V1.4 (14)
  • sequence - Sequence number, used to check if the packets have arrived in the correct order (counts up to 255)
  • physical - The physical DMX512 port this data came from
  • universe - Which universe this packet is meant for
  • data - The data in the packet
  • length - How much DMX data we have (full packet is 18+length)

The following functions are available to use:

  • readPacket - Returns the last Art-Net packet that we received. (Returns ArtnetPacket)
  • readBuffer - Returns the last Art-Net packet that we received for each universe. (Returns an array of ArtnetPacket, one per universe)
  • close - Make sure to run this at the end of your program. Tells the socket to stop running and joins the thread back. (Returns None)
  • version - Returns the library version. (Returns String)

Further information on how it all works can be found in the Art-Net documentation.
Art-Net™ Designed by and Copyright Artistic Licence Engineering Ltd

License

This project is licensed under an MIT License (see the LICENSE file).

python_artnet's People

Contributors

sciencegey avatar

Stargazers

CHONG YOE YAT avatar Ebbe avatar  avatar

Watchers

 avatar Ebbe avatar

python_artnet's Issues

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

Steps to recreate this problem:

  • Make a ArtNet stream with multiple universes. In my example I have 8. The first 3 are active, so there are fixtures that are controlled in those 3 universes.
  • Now run the following example script:
import time
import sys
import python_artnet as Artnet
import os

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.

Not receiving any DMX data

Hey there, sorry if this is the wrong place to ask for help :(

I'm trying to pull DMX information from my DJ decks via Art-Net to control some lights, but unfortunately I can't grab any packets containing DMX data. With debug on, this is the only output I get:

poll! b'Art-Net\x00' b'\x00!' 10 10 10 1 b'6\x19' b'14' 0 0 43981 0 48 b'\xf0\x7f' b'python_artnet\x00\x00\x00\x00\x00' b'python_artnet\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' 1 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 b'\x00\x00\x00' 0 b'\xaa' b'\xbb' b'\xcc' b'\xdd' b'\xee' b'\xff' 0 0 0 0 0 13 192 0 b'\x00\x00\x00\x00\x00\x00' 0 44 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' sent!

This output repeats over and over with none of the bytes changing at all.

Python-artnet is indeed showing up as an interface on my DJ decks, so obviously something is communicating back and forth, but I can't seem to get any data other than what's above. Any help or insight would be super appreciated as I'm super unfamiliar with Art-Net and maybe you might have an idea of what's going on :( Thank you!

Support an arbitrarily large number of universes

I think currently if you have a setup with a large number of universes, the library will throw an error. The library's limit is possibly 16 based on this, the spec allows up to a theoretical maximum of 32,768 universes (though the practical limit is lower).

It's somewhat an edge case, but would be great if this limit could either be configurable, or could be adjusted to accept an arbitrary number of universes. I'm happy to put in a pull request if you have a preferred approach.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.