send dummy command
This commit is contained in:
parent
d900308c5d
commit
8e91a0d950
3 changed files with 27 additions and 2 deletions
|
@ -1,7 +1,8 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
use serde::Serialize;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
#[derive(Deserialize, Default)]
|
#[derive(Serialize, Deserialize, Default)]
|
||||||
pub struct Command {
|
pub struct Command {
|
||||||
pub left: f32,
|
pub left: f32,
|
||||||
pub right: f32,
|
pub right: f32,
|
||||||
|
|
|
@ -4,3 +4,7 @@ version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
serialport = "4.7.2"
|
||||||
|
postcard = "1.1.2"
|
||||||
|
common = { path = "../common" }
|
||||||
|
heapless = "0.7.17"
|
||||||
|
|
|
@ -1,3 +1,23 @@
|
||||||
|
use std::{thread::sleep, time::Duration};
|
||||||
|
|
||||||
|
use common::Command;
|
||||||
|
use postcard::to_vec_cobs;
|
||||||
|
use heapless::Vec;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello, world!");
|
let mut port = serialport::new("/dev/ttyACM0", 1152000)
|
||||||
|
.open().expect("port missing");
|
||||||
|
println!("port open");
|
||||||
|
|
||||||
|
let command = Command { left: 0.0, right: 0.7 };
|
||||||
|
|
||||||
|
let encoded: Vec<u8, 20> = to_vec_cobs(&command).unwrap();
|
||||||
|
|
||||||
|
loop {
|
||||||
|
port.write(&encoded).expect("port write fail");
|
||||||
|
println!("sending");
|
||||||
|
|
||||||
|
sleep(Duration::from_millis(200));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue