mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
manually cleanup a flat accessor in USB crate
This commit is contained in:
parent
be227adde1
commit
1b5eacdb68
2 changed files with 10 additions and 11 deletions
|
|
@ -90,7 +90,7 @@ pub(crate) enum Opcode {
|
|||
}
|
||||
|
||||
// The log crate depends on this API not changing.
|
||||
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)]
|
||||
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Clone)]
|
||||
pub struct UsbString {
|
||||
pub s: String,
|
||||
pub sent: Option<u32>,
|
||||
|
|
@ -149,9 +149,9 @@ impl TryFrom<usize> for UsbDeviceType {
|
|||
|
||||
pub const SERIAL_ASCII_BUFLEN: usize = 512;
|
||||
pub const SERIAL_BINARY_BUFLEN: usize = 128;
|
||||
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)]
|
||||
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Clone)]
|
||||
pub struct UsbSerialAscii {
|
||||
pub s: String<SERIAL_ASCII_BUFLEN>,
|
||||
pub s: String,
|
||||
pub delimiter: Option<char>,
|
||||
}
|
||||
|
||||
|
|
@ -183,7 +183,7 @@ pub struct HIDReportMessage {
|
|||
}
|
||||
|
||||
/// this structure is used to register a USB listener.
|
||||
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)]
|
||||
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Clone)]
|
||||
pub(crate) struct UsbListenerRegistration {
|
||||
pub server_name: String,
|
||||
pub listener_op_id: usize,
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ pub mod api;
|
|||
pub use api::*;
|
||||
use num_traits::*;
|
||||
use packed_struct::PackedStruct;
|
||||
use rkyv::option::ArchivedOption;
|
||||
use trng::api::TrngTestMode;
|
||||
pub use usb_device::device::UsbDeviceState;
|
||||
use xous::{send_message, Message, CID};
|
||||
|
|
@ -319,7 +320,7 @@ impl UsbHid {
|
|||
.or(Err(xous::Error::InternalError))
|
||||
.expect("Internal error");
|
||||
let resp = buf.to_original::<UsbSerialAscii, _>().unwrap();
|
||||
resp.s.to_str().to_string()
|
||||
resp.s
|
||||
}
|
||||
|
||||
/// Blocks until enough binary data has been received to fill the buffer
|
||||
|
|
@ -375,10 +376,8 @@ impl UsbHid {
|
|||
}
|
||||
|
||||
pub fn register_u2f_observer(&self, server_name: &str, action_opcode: usize) {
|
||||
let kr = UsbListenerRegistration {
|
||||
server_name: String::from(server_name),
|
||||
listener_op_id: action_opcode,
|
||||
};
|
||||
let kr =
|
||||
UsbListenerRegistration { server_name: String::from(server_name), listener_op_id: action_opcode };
|
||||
let buf = Buffer::into_buf(kr).unwrap();
|
||||
buf.lend(self.conn, Opcode::RegisterUsbObserver.to_u32().unwrap())
|
||||
.expect("couldn't register listener");
|
||||
|
|
@ -428,7 +427,7 @@ impl UsbHid {
|
|||
let report = buf.as_flat::<HIDReportMessage, _>().unwrap();
|
||||
|
||||
match &report.data {
|
||||
rkyv::core_impl::ArchivedOption::Some(data) => {
|
||||
ArchivedOption::Some(data) => {
|
||||
let mut ret = HIDReport::default();
|
||||
|
||||
for (&s, d) in data.0[..data.0.len() as usize].iter().zip(ret.0.iter_mut()) {
|
||||
|
|
@ -437,7 +436,7 @@ impl UsbHid {
|
|||
|
||||
Ok(ret)
|
||||
}
|
||||
rkyv::core_impl::ArchivedOption::None => Err(xous::Error::UnknownError),
|
||||
ArchivedOption::None => Err(xous::Error::UnknownError),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue