stupidArtnet


NamestupidArtnet JSON
Version 1.5.0 PyPI version JSON
download
home_pagehttps://github.com/cpvalente/stupidArtnet
Summary(Very) Simple implementation of the Art-Net protocol
upload_time2024-03-16 10:12:55
maintainer
docs_urlNone
authorcpvalente
requires_python>=3.6
licenseMIT
keywords lighting dmx lighting control
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![.github/workflows/publish-to-pypi.yml](https://github.com/cpvalente/stupidArtnet/actions/workflows/publish-to-pypi.yml/badge.svg)](https://github.com/cpvalente/stupidArtnet/actions/workflows/publish-to-pypi.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)

# StupidArtnet

(Very) Simple Art-Net implementation in Python (compatible with micro python)

#### Table of Contents
- [Installing from github](#installing-from-github)
- [Installing from Pip](#installing-from-pip)
- [Server Basics](#receiving-data)
- [Client Basics](#basics)
- [Persistent sending](#persistent-sending)
- [Example code](#example-code)
- [Notes](#notes)
- [Art-Net](#art-net)
- [Nets and Subnets](#nets-and-subnets)
- [License](#license)

### Installing from github
You can get up and running quickly cloning from github.
Run the example file to make sure everything is up to scratch
```bash
$ git clone https://github.com/cpvalente/stupidArtnet.git
$ cd stupidArtnet
$ python3 examples/example.py
```
### Installing from Pip
The project is now available in [Pip](https://pypi.org/project/stupidArtnet/) and can be installed with
```pip install stupidartnet```

### Receiving Data
You can use the server module to receive Art-Net data
```python
# a StupidArtnetServer can listen to a specific universe
# and return new data to a user defined callback
a = StupidArtnetServer(universe=0, callback_function=test_callback)

# if you prefer, you can also inspect the latest
# received data yourself
buffer = a.get_buffer()

```
### Persistent sending
Usually Artnet devices (and DMX in general) transmit data at a rate of no less than 30Hz.
You can do this with StupidArtnet by using its threaded abilities

```python
# TO SEND PERSISTENT SIGNAL YOU CAN START THE THREAD
a.start()

# AND MODIFY THE DATA AS YOU GO
for x in range(100):
	for i in range(packet_size):	# Fill buffer with random stuff
		packet[i] = random.randint(0, 255)
	a.set(packet)
	time.sleep(.2)

# ... REMEMBER TO CLOSE THE THREAD ONCE YOU ARE DONE
a.stop()

```
### Example code
See examples folder inside the package directory
- [x] Use with Tkinter
- [x] Send Art-Net (client)
- [x] Receive Art-Net (server)

### Notes

Artnet libraries tend to be complicated and hard to get off the ground. Sources were either too simple and didn't explain the workings or become too complex by fully implementing the protocol. <br />
This is meant as an implementation focusing on DMX over Artnet only (ArtDMX).

I am also doing my best to comment the sections where the packets is build. In an effort to help you understand the protocol and be able to extend it for a more case specific use.

Users looking to send a few channels to control a couple of LEDs, projectors or media servers can use this as reference.

Are you running several universes with different fixture types? I would recommend [ArtnetLibs](https://github.com/OpenLightingProject/libartnet) or the [Python Wrapper for Artnet Libs](https://github.com/haum/libartnet)

### Art-Net

Getting things running with protocol is pretty simple. just shove the protocol header into your data array and send it to the right place.
Usually Artnet devices are in the range of 2.x.x.x or 10.x.x.x. This is a convention however is not forcefully implemented.
I have filled the data to represent a ArtDmx packet


| Byte   | Value  | Description  |
| -----: | :----: | ------------ |
| 0      | A      | Header       |
| 1      | r      | "            |
| 2      | t      | "            |
| 3      | -      | "            |
| 4      | N      | "            |
| 5      | e      | "            |
| 6      | t      | "            |
| 7      | 0x00   | "            |
| 8      | 0x00   | OpCode Low   |
| 9      | 0x500  | OpCode High  (ArtDmx)         |
| 10     | 0x00   | Protocol V High               |
| 11     | 14     | Protocol V Low (currently 14) |
| 12     | 0x00   | Sequence** (0x00 to disable)  |
| 13     | int 8  | Physical     |
| 14     | int 8  | Sub + Uni ***                 |
| 15     | int 8  | Net ***      |
| 16     | int 8  | Length High (typically 512)   |
| 17     | int 8  | Length Low   |
| -      | -      | Append your packet here       |

** To allow the receiver to ensure packets are received in the right order <br />
*** By spec should look like this:
| Bit 15   | Bits 14-8  | Bits 7-4  | Bits 3-0  |
| :------- | :--------- | :-------- | :-------- |
| 0        | Net        | Subnet    | Universe  |

Note: This is true for the current version of Artnet 4 (v14), as [defined here](https://artisticlicence.com/WebSiteMaster/User%20Guides/art-net.pdf)

### Nets and Subnets

Artnet uses the concept of Universes and Subnets for data routing. I simplified here defaulting to use a 256 value universe. This will then be divided into low and high uint8 and look correct either way (Universe 17 will be Universe 1 of Subnet 2). In this case the net will always be 0.
This will look correct and behave fine for smaller networks, wanting to be able to specify Universes, Subnets and Nets you can disable simplification and give values as needed. <br />
The spec for Artnet 4 applies here: 128 Nets contain 16 Subnets which contain 16 Universes. 128 * 16 * 16 = 32 768 Universes

```python
# Create a StupidArtnet instance with the relevant values

# By default universe is simplified to a value between 0 - 255
# this should suffice for anything not using subnets
# on sending universe will be masked to two values
# making the use of subnets invisible

universe = 17	# equivalent to universe 1 subnet 1
a = StupidArtnet(target_ip, universe, packet_size)


#############################################

# You can also disable simplification
a.set_simplified(False)

# Add net and subnet value
# Values here are 0 based
a.set_universe(15)
a.set_subnet(15)
a.set_net(127)
```

### License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cpvalente/stupidArtnet",
    "name": "stupidArtnet",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "LIGHTING,DMX,LIGHTING CONTROL",
    "author": "cpvalente",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/a6/52/5d91f6782b5b4da3e5e7c60436609cc44239e007b95c94b2bcbc6e8c1d99/stupidArtnet-1.5.0.tar.gz",
    "platform": null,
    "description": "[![.github/workflows/publish-to-pypi.yml](https://github.com/cpvalente/stupidArtnet/actions/workflows/publish-to-pypi.yml/badge.svg)](https://github.com/cpvalente/stupidArtnet/actions/workflows/publish-to-pypi.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)\n\n# StupidArtnet\n\n(Very) Simple Art-Net implementation in Python (compatible with micro python)\n\n#### Table of Contents\n- [Installing from github](#installing-from-github)\n- [Installing from Pip](#installing-from-pip)\n- [Server Basics](#receiving-data)\n- [Client Basics](#basics)\n- [Persistent sending](#persistent-sending)\n- [Example code](#example-code)\n- [Notes](#notes)\n- [Art-Net](#art-net)\n- [Nets and Subnets](#nets-and-subnets)\n- [License](#license)\n\n### Installing from github\nYou can get up and running quickly cloning from github.\nRun the example file to make sure everything is up to scratch\n```bash\n$ git clone https://github.com/cpvalente/stupidArtnet.git\n$ cd stupidArtnet\n$ python3 examples/example.py\n```\n### Installing from Pip\nThe project is now available in [Pip](https://pypi.org/project/stupidArtnet/) and can be installed with\n```pip install stupidartnet```\n\n### Receiving Data\nYou can use the server module to receive Art-Net data\n```python\n# a StupidArtnetServer can listen to a specific universe\n# and return new data to a user defined callback\na = StupidArtnetServer(universe=0, callback_function=test_callback)\n\n# if you prefer, you can also inspect the latest\n# received data yourself\nbuffer = a.get_buffer()\n\n```\n### Persistent sending\nUsually Artnet devices (and DMX in general) transmit data at a rate of no less than 30Hz.\nYou can do this with StupidArtnet by using its threaded abilities\n\n```python\n# TO SEND PERSISTENT SIGNAL YOU CAN START THE THREAD\na.start()\n\n# AND MODIFY THE DATA AS YOU GO\nfor x in range(100):\n\tfor i in range(packet_size):\t# Fill buffer with random stuff\n\t\tpacket[i] = random.randint(0, 255)\n\ta.set(packet)\n\ttime.sleep(.2)\n\n# ... REMEMBER TO CLOSE THE THREAD ONCE YOU ARE DONE\na.stop()\n\n```\n### Example code\nSee examples folder inside the package directory\n- [x] Use with Tkinter\n- [x] Send Art-Net (client)\n- [x] Receive Art-Net (server)\n\n### Notes\n\nArtnet libraries tend to be complicated and hard to get off the ground. Sources were either too simple and didn't explain the workings or become too complex by fully implementing the protocol. <br />\nThis is meant as an implementation focusing on DMX over Artnet only (ArtDMX).\n\nI am also doing my best to comment the sections where the packets is build. In an effort to help you understand the protocol and be able to extend it for a more case specific use.\n\nUsers looking to send a few channels to control a couple of LEDs, projectors or media servers can use this as reference.\n\nAre you running several universes with different fixture types? I would recommend [ArtnetLibs](https://github.com/OpenLightingProject/libartnet) or the [Python Wrapper for Artnet Libs](https://github.com/haum/libartnet)\n\n### Art-Net\n\nGetting things running with protocol is pretty simple. just shove the protocol header into your data array and send it to the right place.\nUsually Artnet devices are in the range of 2.x.x.x or 10.x.x.x. This is a convention however is not forcefully implemented.\nI have filled the data to represent a ArtDmx packet\n\n\n| Byte   | Value  | Description  |\n| -----: | :----: | ------------ |\n| 0      | A      | Header       |\n| 1      | r      | \"            |\n| 2      | t      | \"            |\n| 3      | -      | \"            |\n| 4      | N      | \"            |\n| 5      | e      | \"            |\n| 6      | t      | \"            |\n| 7      | 0x00   | \"            |\n| 8      | 0x00   | OpCode Low   |\n| 9      | 0x500  | OpCode High  (ArtDmx)         |\n| 10     | 0x00   | Protocol V High               |\n| 11     | 14     | Protocol V Low (currently 14) |\n| 12     | 0x00   | Sequence** (0x00 to disable)  |\n| 13     | int 8  | Physical     |\n| 14     | int 8  | Sub + Uni ***                 |\n| 15     | int 8  | Net ***      |\n| 16     | int 8  | Length High (typically 512)   |\n| 17     | int 8  | Length Low   |\n| -      | -      | Append your packet here       |\n\n** To allow the receiver to ensure packets are received in the right order <br />\n*** By spec should look like this:\n| Bit 15   | Bits 14-8  | Bits 7-4  | Bits 3-0  |\n| :------- | :--------- | :-------- | :-------- |\n| 0        | Net        | Subnet    | Universe  |\n\nNote: This is true for the current version of Artnet 4 (v14), as [defined here](https://artisticlicence.com/WebSiteMaster/User%20Guides/art-net.pdf)\n\n### Nets and Subnets\n\nArtnet uses the concept of Universes and Subnets for data routing. I simplified here defaulting to use a 256 value universe. This will then be divided into low and high uint8 and look correct either way (Universe 17 will be Universe 1 of Subnet 2). In this case the net will always be 0.\nThis will look correct and behave fine for smaller networks, wanting to be able to specify Universes, Subnets and Nets you can disable simplification and give values as needed. <br />\nThe spec for Artnet 4 applies here: 128 Nets contain 16 Subnets which contain 16 Universes. 128 * 16 * 16 = 32\u00a0768 Universes\n\n```python\n# Create a StupidArtnet instance with the relevant values\n\n# By default universe is simplified to a value between 0 - 255\n# this should suffice for anything not using subnets\n# on sending universe will be masked to two values\n# making the use of subnets invisible\n\nuniverse = 17\t# equivalent to universe 1 subnet 1\na = StupidArtnet(target_ip, universe, packet_size)\n\n\n#############################################\n\n# You can also disable simplification\na.set_simplified(False)\n\n# Add net and subnet value\n# Values here are 0 based\na.set_universe(15)\na.set_subnet(15)\na.set_net(127)\n```\n\n### License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "(Very) Simple implementation of the Art-Net protocol",
    "version": "1.5.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/cpvalente/stupidArtnet/issues",
        "Homepage": "https://github.com/cpvalente/stupidArtnet"
    },
    "split_keywords": [
        "lighting",
        "dmx",
        "lighting control"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4ee76245e2041c3eeca893489bc0d47ed92391b8252e638e962bb1ceb588de8f",
                "md5": "b206fe99c17558218edee94f15eece1c",
                "sha256": "531616893a88f6db7084049b9a5d9af1f4b3a2da75b64b2b0cf2d681943e28cd"
            },
            "downloads": -1,
            "filename": "stupidArtnet-1.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b206fe99c17558218edee94f15eece1c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 12308,
            "upload_time": "2024-03-16T10:12:54",
            "upload_time_iso_8601": "2024-03-16T10:12:54.868120Z",
            "url": "https://files.pythonhosted.org/packages/4e/e7/6245e2041c3eeca893489bc0d47ed92391b8252e638e962bb1ceb588de8f/stupidArtnet-1.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a6525d91f6782b5b4da3e5e7c60436609cc44239e007b95c94b2bcbc6e8c1d99",
                "md5": "781abffa99caa52b6e0989b2e7e5bde5",
                "sha256": "7262530620c553c13a8a186b2a26d54f36af6073421ba2d88a11cd18c3828217"
            },
            "downloads": -1,
            "filename": "stupidArtnet-1.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "781abffa99caa52b6e0989b2e7e5bde5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 14606,
            "upload_time": "2024-03-16T10:12:55",
            "upload_time_iso_8601": "2024-03-16T10:12:55.901314Z",
            "url": "https://files.pythonhosted.org/packages/a6/52/5d91f6782b5b4da3e5e7c60436609cc44239e007b95c94b2bcbc6e8c1d99/stupidArtnet-1.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-16 10:12:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cpvalente",
    "github_project": "stupidArtnet",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "stupidartnet"
}
        
Elapsed time: 0.30288s