added rust documentation comments
This commit is contained in:
@@ -3,6 +3,10 @@ name = "emergency_stop"
|
||||
version = "0.1.0"
|
||||
authors = ["Simon Wörner <git@simon-woerner.de>"]
|
||||
|
||||
[[bin]]
|
||||
name = "emergency_stop-test"
|
||||
doc = false
|
||||
|
||||
[features]
|
||||
measure = ["kawaii/measure"]
|
||||
|
||||
|
||||
@@ -18,6 +18,10 @@ pub struct EmergencyStop {
|
||||
}
|
||||
|
||||
impl EmergencyStop {
|
||||
/// Constructs a new `EmergencyStop` and starts poll thread.
|
||||
///
|
||||
/// # Parameter
|
||||
/// - `stop_port` GPIO Port number of emergency stop pin.
|
||||
pub fn new(stop_port: u8) -> std::io::Result<Self> {
|
||||
let name = format!("EmergencyStop(port = {})", stop_port);
|
||||
let state = Arc::new(AtomicBool::new(false));
|
||||
@@ -29,11 +33,12 @@ impl EmergencyStop {
|
||||
.spawn(move || EmergencyStop::thread(&mut port, state_clone))?;
|
||||
|
||||
Ok(EmergencyStop {
|
||||
thread: Some(thread),
|
||||
state: state,
|
||||
})
|
||||
thread: Some(thread),
|
||||
state: state,
|
||||
})
|
||||
}
|
||||
|
||||
/// Emergency stop poll thread
|
||||
fn thread(port: &mut AsyncPort, state: Arc<AtomicBool>) {
|
||||
#[cfg(feature = "measure")]
|
||||
let mut measure = Measure::new(format!("EmergencyStop(port = {})", port.port.number));
|
||||
@@ -86,6 +91,7 @@ impl EmergencyStop {
|
||||
}
|
||||
|
||||
impl Drop for EmergencyStop {
|
||||
/// Set emergency stop and join poll thread.
|
||||
fn drop(&mut self) {
|
||||
self.state.store(true, Ordering::Relaxed);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user