diff --git a/src/class.rs b/src/class.rs index 93c9f52..80ded5c 100644 --- a/src/class.rs +++ b/src/class.rs @@ -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(); + } } } diff --git a/src/pipe.rs b/src/pipe.rs index 35336c7..d54e97f 100644 --- a/src/pipe.rs +++ b/src/pipe.rs @@ -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;