Provide some debug output.
This commit is contained in:
parent
39147d45f4
commit
52d734d95f
3 changed files with 12 additions and 5 deletions
5
hostcontrol/Cargo.lock
generated
5
hostcontrol/Cargo.lock
generated
|
|
@ -1446,6 +1446,7 @@ dependencies = [
|
|||
"eframe",
|
||||
"egui",
|
||||
"env_logger",
|
||||
"log",
|
||||
"nalgebra",
|
||||
"nalgebra-macros",
|
||||
"serialport",
|
||||
|
|
@ -1759,9 +1760,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.27"
|
||||
version = "0.4.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
|
||||
checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
|
||||
|
||||
[[package]]
|
||||
name = "mach2"
|
||||
|
|
|
|||
|
|
@ -11,3 +11,4 @@ nalgebra-macros = "^0.2.2"
|
|||
env_logger = "0.11.8"
|
||||
egui = "0.31.1"
|
||||
eframe = "0.31.1"
|
||||
log = "0.4.29"
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use std::time::Duration;
|
||||
use thiserror::Error;
|
||||
use log::debug;
|
||||
|
||||
fn new_camera_rotation(theta: f64) -> nalgebra::Matrix3<f64> {
|
||||
nalgebra::matrix![
|
||||
|
|
@ -55,6 +56,8 @@ pub type StageIOResult<T> = std::result::Result<T, StageIOError>;
|
|||
impl StageIO {
|
||||
pub fn new(port: &str, speed: u32) -> StageIOResult<Self> {
|
||||
let serial = serialport::new(port, speed).timeout(Duration::from_secs(60)).open()?;
|
||||
// TODO: read and discard initial characters; some devices like to be
|
||||
// chatty on start-up.
|
||||
Ok(Self { serial })
|
||||
}
|
||||
|
||||
|
|
@ -71,10 +74,12 @@ impl StageIO {
|
|||
}
|
||||
|
||||
// Send request and wait for response deliminated with a newline
|
||||
fn send_request<S: AsRef<str>>(&mut self, command: S) -> StageIOResult<String> {
|
||||
pub fn send_request<S: AsRef<str>>(&mut self, command: S) -> StageIOResult<String> {
|
||||
debug!("->: {:?}", command.as_ref());
|
||||
self.serial.write_all(command.as_ref().as_bytes()).map_err(|e| StageIOError::Write(e))?;
|
||||
let res = self.receive_until("\n")?;
|
||||
Ok(res.trim().to_string())
|
||||
let response = self.receive_until("\n")?;
|
||||
debug!("<-: {:?}", response);
|
||||
Ok(response.trim().to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue