-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example of receiving ArtNet and fix formatting in readme
- Loading branch information
Timoteus Ruotsalainen
committed
Nov 11, 2024
1 parent
f8b6cad
commit 985ec70
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use artnet_protocol::*; | ||
use std::net::{ToSocketAddrs, UdpSocket}; | ||
|
||
fn main() { | ||
let socket = UdpSocket::bind(("0.0.0.0", 6454)).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::Output(output) => { | ||
println!( | ||
"port {:?} data: {:?}", | ||
u16::from(output.port_address), | ||
output.data | ||
) | ||
} | ||
_ => {} | ||
} | ||
} | ||
} |