1use open_dmx::DMXSerial;
2
3fn main() {
4 let mut dmx = DMXSerial::open("COM3").unwrap();
5 dmx.set_sync();
6 loop {
7 let _ = strobe(&mut dmx);
8 println!("Device has been disconnected! Reopening...");
9 match dmx.reopen() {
10 Ok(_) => println!("Device has been reopened!"),
11 Err(e) => {
12 println!("Error reopening device: {}", e);
13 println!("Waiting 1 second before trying again...");
14 std::thread::sleep(std::time::Duration::from_secs(1));
15 },
16 }
17 }
18}
19
20fn strobe(dmx: &mut DMXSerial) -> Result<(), Box<dyn std::error::Error>>{
21 println!("Sending strobe packets...");
22 loop {
23 dmx.set_channels([255; 512]);
24 dmx.update()?;
25 dmx.set_channels([0; 512]);
26 dmx.update()?;
27 }
28}