diff --git a/green/Marlin b/green/Marlin index 076afd2..b58bbb5 160000 --- a/green/Marlin +++ b/green/Marlin @@ -1 +1 @@ -Subproject commit 076afd2c617110c8f2e7df062329e32bd0f0269b +Subproject commit b58bbb57e5ca2a5e6d7af0ade2c191b2e89f6081 diff --git a/red/justfile b/red/justfile index e29dbb7..a02cc9b 100644 --- a/red/justfile +++ b/red/justfile @@ -3,5 +3,5 @@ build: rrun: #scp -r ./src olimex@muele.local:red/ - rsync -rv --filter=':- .gitignore' ../red olimex@muele.local: - ssh olimex@muele.local "cd red; /home/olimex/.cargo/bin/cargo run" \ No newline at end of file + rsync -rvu --filter=':- .gitignore' ../red olimex@muele.local: + ssh olimex@muele.local "cd red; /home/olimex/.cargo/bin/cargo run;" \ No newline at end of file diff --git a/red/src/main.rs b/red/src/main.rs index dae3285..075327e 100644 --- a/red/src/main.rs +++ b/red/src/main.rs @@ -57,21 +57,20 @@ async fn main() -> tokio_serial::Result<()> { let (mut writer, mut reader) = LineCodec.framed(port).split(); println!("Starting read."); let reader_task = async move { + let mut counter = 0; while let Some(line_result) = reader.next().await { let line = line_result.expect("Failed to read line"); - println!("{}", line); - } - }; - let writer_task = async move { - loop { - if let Err(e) = writer.send("M114\n".into()).await { - println!("{:?}", e); - break; + if line.contains("ok") || line.contains("Loaded") { + if let Err(e) = writer.send("M114\n".into()).await { + println!("{:?}", e); + break; + } } - tokio::time::sleep(std::time::Duration::from_secs(1)).await; + counter += 1; + println!("updates received: {}", counter); } }; - tokio::join!(writer_task, reader_task); + reader_task.await; Ok(()) } \ No newline at end of file