forked from fafo/microscope-control
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",
|
"eframe",
|
||||||
"egui",
|
"egui",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
|
"log",
|
||||||
"nalgebra",
|
"nalgebra",
|
||||||
"nalgebra-macros",
|
"nalgebra-macros",
|
||||||
"serialport",
|
"serialport",
|
||||||
|
|
@ -1759,9 +1760,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.27"
|
version = "0.4.29"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
|
checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mach2"
|
name = "mach2"
|
||||||
|
|
|
||||||
|
|
@ -11,3 +11,4 @@ nalgebra-macros = "^0.2.2"
|
||||||
env_logger = "0.11.8"
|
env_logger = "0.11.8"
|
||||||
egui = "0.31.1"
|
egui = "0.31.1"
|
||||||
eframe = "0.31.1"
|
eframe = "0.31.1"
|
||||||
|
log = "0.4.29"
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
use log::debug;
|
||||||
|
|
||||||
fn new_camera_rotation(theta: f64) -> nalgebra::Matrix3<f64> {
|
fn new_camera_rotation(theta: f64) -> nalgebra::Matrix3<f64> {
|
||||||
nalgebra::matrix![
|
nalgebra::matrix![
|
||||||
|
|
@ -55,6 +56,8 @@ pub type StageIOResult<T> = std::result::Result<T, StageIOError>;
|
||||||
impl StageIO {
|
impl StageIO {
|
||||||
pub fn new(port: &str, speed: u32) -> StageIOResult<Self> {
|
pub fn new(port: &str, speed: u32) -> StageIOResult<Self> {
|
||||||
let serial = serialport::new(port, speed).timeout(Duration::from_secs(60)).open()?;
|
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 })
|
Ok(Self { serial })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,10 +74,12 @@ impl StageIO {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send request and wait for response deliminated with a newline
|
// 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))?;
|
self.serial.write_all(command.as_ref().as_bytes()).map_err(|e| StageIOError::Write(e))?;
|
||||||
let res = self.receive_until("\n")?;
|
let response = self.receive_until("\n")?;
|
||||||
Ok(res.trim().to_string())
|
debug!("<-: {:?}", response);
|
||||||
|
Ok(response.trim().to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue