Trangar / artnet_protocol

A 1:1 implementation of the ArtNet protocol, in Rust
MIT License
22 stars 18 forks source link

Invalid Length Fields #7

Closed Firionus closed 4 years ago

Firionus commented 4 years ago

length != data.len()

The crate currently allows construction of ArtDmx packets where the length field does not equal the length of the Data field:

    let artnet_protocol_packet = ArtCommand::Output(Output {
        length: 3,
        data: vec![0xff, 0xff],
        ..Output::default()
    });

This should not be possible. I think setting the length field should be done automatically by artnet_protocol.

wrong length DMX Data

The Art-Net Spec says on page 48 that the Length

should be an even number in the range 2 – 512.

Currently, ArtDmx packets can be constructed with

These should all be impossible to construct.

In case of uneven length I think we should pad with a zero to the next even number. For example if the user wants to send vec![0xff, 0xff, 0xff], I think we should automatically pad with a zero to get vec![0xff, 0xff, 0xff, 0x00].

VictorKoenders commented 4 years ago

Closed in #8