Require Send and Debug on GcodeCommand not on mpsc
This commit is contained in:
parent
13781bd29e
commit
c6c0f65f7a
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ pub struct State {
|
|||
}
|
||||
|
||||
pub struct Printer {
|
||||
pub printer_in: Sender<Box<dyn GcodeCommand + Send>>,
|
||||
pub printer_in: Sender<Box<dyn GcodeCommand>>,
|
||||
pub state: Rc<State>,
|
||||
}
|
||||
|
||||
|
@ -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::<Box<dyn GcodeCommand + Send>>(32);
|
||||
let (tx, mut rx) = channel::<Box<dyn GcodeCommand>>(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;
|
||||
|
|
Loading…
Reference in a new issue