Compare commits

...

2 commits

Author SHA1 Message Date
Fl1tzi b26a8834c6
add break 2023-10-08 01:01:40 +02:00
Fl1tzi 305d0ea93e
small updates 2023-10-08 00:59:03 +02:00
2 changed files with 11 additions and 7 deletions

View file

@ -35,6 +35,12 @@ impl Display for DeviceError {
} }
} }
impl Display for Device {
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(formatter, "{}", self.serial)
}
}
/// Handles everything related to a single device /// Handles everything related to a single device
pub struct Device { pub struct Device {
modules: HashMap<u8, ModuleController>, modules: HashMap<u8, ModuleController>,
@ -162,8 +168,9 @@ impl Device {
/// listener for button press changes on the device /// listener for button press changes on the device
#[tracing::instrument(skip_all, fields(serial = self.serial))] #[tracing::instrument(skip_all, fields(serial = self.serial))]
pub async fn key_listener(&mut self) { pub async fn key_listener(&mut self) {
let reader = self.device.get_reader();
loop { loop {
match self.device.get_reader().read(7.0).await { match reader.read(7.0).await {
Ok(v) => { Ok(v) => {
trace!("{:?}", v); trace!("{:?}", v);
for update in v { for update in v {
@ -238,9 +245,9 @@ impl Device {
} }
pub async fn execute_sh(command: &str) { pub async fn execute_sh(command: &str) {
match Command::new("sh").arg(command).output().await { match Command::new("sh").arg("-c").arg(command).spawn() {
Ok(o) => debug!("Command \'{}\' returned: {}", command, o.status), Ok(_) => debug!("Command \'{}\' returned", command),
Err(e) => error!("Command \'{}\' failed: {}", command, e), Err(_) => error!("Command \'{}\' failed", command),
} }
} }

View file

@ -170,9 +170,6 @@ pub async fn start_device(
info!("Connected"); info!("Connected");
device.init_modules().await; device.init_modules().await;
device.key_listener().await; device.key_listener().await;
if !device.has_modules() {
warn!("All modules have failed to start");
}
Some(device) Some(device)
} }
Err(e) => { Err(e) => {