Crate artnet_protocol[][src]

Contains the ArtCommand enum which holds the entire ArtNet protocol v4, as per https://artisticlicence.com/WebSiteMaster/User%20Guides/art-net.pdf

let socket = UdpSocket::bind(("0.0.0.0", 6454))?;
let broadcast_addr = ("255.255.255.255", 6454).to_socket_addrs().unwrap().next().unwrap();
socket.set_broadcast(true).unwrap();
let buff = ArtCommand::Poll(Poll::default()).into_buffer().unwrap();
socket.send_to(&buff, &broadcast_addr).unwrap();

loop {
    let mut buffer = [0u8; 1024];
    let (length, addr) = socket.recv_from(&mut buffer).unwrap();
    let command = ArtCommand::from_buffer(&buffer[..length]).unwrap();
     
    println!("Received {:?}", command);
    match command {
        ArtCommand::Poll(poll) => {
            // This will most likely be our own poll request, as this is broadcast to all devices on the network
        },
        ArtCommand::PollReply(reply) => {
            // This is an ArtNet node on the network. We can send commands to it like this:
            let command = ArtCommand::Output(Output {
                length: 5, // must match your data.len()
                data: vec![1, 2, 3, 4, 5], // The data we're sending to the node
                ..Output::default()
            });
            let bytes = command.into_bytes().unwrap();
            socket.send_to(&bytes, &addr).unwrap();
        },
        _ => {}
    }
}

Re-exports

pub extern crate failure;
pub extern crate bitflags;
pub extern crate byteorder;

Structs

ArtTalkToMe

The TalkToMe flag, as to be used in the Poll and PollReply message

Output

ArtDmx is the data packet used to transfer DMX512 data. The format is identical for Node to Controller, Node to Node and Controller to Node.

Poll

Used to poll the nodes in the network

PollReply

Gets send by the nodes in the network as a response to the Poll message

Enums

ArtCommand

The ArtCommand, to be used for ArtNet.

Constants

ARTNET_HEADER

The ArtNet header. This is the first 8 bytes of each message, and contains the text "Art-Net\0"

ARTNET_PROTOCOL_VERSION

The protocol version. Anything above [4, 0] seems to work for the devices that this library was tested on.

Type Definitions

Result

The result that this crate uses