Skip to content

Commit

Permalink
Make jlctl usable as a library crate
Browse files Browse the repository at this point in the history
  • Loading branch information
nilclass committed Feb 13, 2024
1 parent 87ae245 commit 3617ee2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/device_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::collections::HashMap;
pub struct DeviceManager {
path: Option<String>,
device: Option<Device>,
log_path: String,
}

#[derive(Serialize)]
Expand All @@ -33,7 +34,7 @@ impl DeviceManager {
} else {
debug!("Initialize DeviceManager, with dynamic port detection");
}
Self { path, device: None }
Self { path, device: None, log_path: "log.txt".to_string() }
}

pub fn status(&mut self) -> Result<Status> {
Expand Down Expand Up @@ -67,9 +68,13 @@ impl DeviceManager {
}
}

pub fn set_log_path(&mut self, log_path: String) {
self.log_path = log_path;
}

fn open(&mut self) -> Result<&mut Device> {
let port_path = self.port_path()?;
let device = Device::new(port_path.clone(), "log.txt".to_string())?;
let device = Device::new(port_path.clone(), self.log_path.clone())?;
self.device = Some(device);
log::info!("Connected to jumperless on port {}", port_path);
Ok(self.device.as_mut().unwrap())
Expand Down
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pub mod device;
pub mod device_manager;
pub mod parser;
pub mod server;
pub mod types;
pub mod validate;

0 comments on commit 3617ee2

Please sign in to comment.