mirror of
https://github.com/trussed-dev/usbd-ccid.git
synced 2026-06-20 04:16:20 -07:00
Avoid panics in class
This commit is contained in:
committed by
sosthene-nitrokey
parent
edfb8584d5
commit
930982e25c
+11
-5
@@ -99,9 +99,9 @@ where
|
||||
Some(self.string_index),
|
||||
)?;
|
||||
writer.write(FUNCTIONAL_INTERFACE, &FUNCTIONAL_INTERFACE_DESCRIPTOR)?;
|
||||
writer.endpoint(&self.pipe.write).unwrap();
|
||||
writer.endpoint(&self.read).unwrap();
|
||||
// writer.endpoint(&self.interrupt).unwrap();
|
||||
writer.endpoint(&self.pipe.write).ok();
|
||||
writer.endpoint(&self.read).ok();
|
||||
// writer.endpoint(&self.interrupt).ok();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -179,7 +179,10 @@ where
|
||||
ClassRequest::GetDataRates => {
|
||||
transfer.accept_with_static(&DATA_RATE_BPS).ok();
|
||||
}
|
||||
_ => panic!("unexpected direction for {:?}", &request),
|
||||
_ => {
|
||||
error!("unexpected direction for {:?}", &request);
|
||||
self.pipe.reset_state();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +222,10 @@ where
|
||||
// transfer.reject().ok();
|
||||
// todo!();
|
||||
}
|
||||
_ => panic!("unexpected direction for {:?}", &request),
|
||||
_ => {
|
||||
error!("unexpected direction for {:?}", &request);
|
||||
self.pipe.reset_state();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ where
|
||||
/// Reset the state of the CCID driver
|
||||
///
|
||||
/// This is done on unexpected input instead of panicking
|
||||
fn reset_state(&mut self) {
|
||||
pub fn reset_state(&mut self) {
|
||||
self.seq = 0;
|
||||
self.state = State::Idle;
|
||||
self.sent = 0;
|
||||
|
||||
Reference in New Issue
Block a user