diff --git a/red/src/printer/gcode.rs b/red/src/printer/gcode.rs index 8e9e075..d529f9f 100644 --- a/red/src/printer/gcode.rs +++ b/red/src/printer/gcode.rs @@ -1,7 +1,9 @@ +use std::fmt::Debug; + use lazy_static::lazy_static; use regex::Regex; -pub trait GcodeCommand { +pub trait GcodeCommand: Debug + Send { fn command(&self) -> &str; fn parse_reply(&self, reply: &str) -> GcodeReply; } diff --git a/red/src/printer/mod.rs b/red/src/printer/mod.rs index 20fd622..83676cd 100644 --- a/red/src/printer/mod.rs +++ b/red/src/printer/mod.rs @@ -21,7 +21,7 @@ pub struct State { } pub struct Printer { - pub printer_in: Sender>, + pub printer_in: Sender>, pub state: Rc, } @@ -35,9 +35,12 @@ impl Printer { .expect("Unable to set serial port exclusive to false"); let connection = LineCodec.framed(port); - let (tx, mut rx) = channel::>(32); + let (tx, mut rx) = channel::>(32); tokio::spawn(async move { let (mut printer_tx, mut printer_rx) = connection.split(); + + // The printer will send some info after connecting. We need to wait for this + // to be received as it will otherwise stop responding for some reason: while let Some(stuff) = printer_rx.next().await { if stuff.map(|s| s.contains("Loaded")).unwrap_or(false) { break;