fix regression in usb-device

This commit is contained in:
bunnie 2022-06-14 17:09:09 +08:00
parent c687f7dc02
commit 0cdd9d9920

View file

@ -25,12 +25,9 @@ use hosted::*;
use num_traits::*;
#[cfg(any(target_os = "none", target_os = "xous"))]
use usb_device_xous::KeyboardLedsReport;
<<<<<<< HEAD
use usbd_human_interface_device::device::fido::RawFidoMsg;
#[cfg(any(target_os = "none", target_os = "xous"))]
use usbd_human_interface_device::device::fido::RawFidoInterface;
=======
>>>>>>> origin/dither2
use xous::{msg_scalar_unpack, msg_blocking_scalar_unpack};
use core::num::NonZeroU8;
use std::collections::BTreeMap;
@ -47,10 +44,6 @@ use usbd_human_interface_device::device::keyboard::NKROBootKeyboardInterface;
use usbd_human_interface_device::prelude::*;
#[cfg(any(target_os = "none", target_os = "xous"))]
use num_enum::FromPrimitive as EnumFromPrimitive;
#[cfg(any(target_os = "none", target_os = "xous"))]
use core::ops::{DerefMut, Deref};
#[cfg(any(target_os = "none", target_os = "xous"))]
use usbd_human_interface_device::device::fido::{FidoInterface, FidoMsg};
use embedded_time::Clock;
use std::convert::TryInto;
@ -108,11 +101,7 @@ fn main() -> ! {
None
).unwrap();
}
<<<<<<< HEAD
let mut fido_listener: Option<xous::MessageEnvelope> = None;
=======
let mut fido_blocker: Option<xous::MessageEnvelope> = None;
>>>>>>> origin/dither2
loop {
let msg = xous::receive_message(usbdev_sid).unwrap();
match FromPrimitive::from_usize(msg.body.id()) {
@ -120,13 +109,8 @@ fn main() -> ! {
xous::return_scalar2(msg.sender, 0, 1).expect("couldn't return status");
}),
Some(Opcode::U2fRxDeferred) => {
<<<<<<< HEAD
// block any rx requests forever
fido_listener = Some(msg);
=======
// this will prevent the FIDO stack from ever moving forward
fido_blocker = Some(msg);
>>>>>>> origin/dither2
}
Some(Opcode::Quit) => {
break;
@ -147,11 +131,7 @@ fn main() -> ! {
}
}
}
<<<<<<< HEAD
log::info!("consuming listener: {:?}", fido_listener);
=======
log::info!("Statement to consume the blocked message, preventing it from being dropped: {:?}", fido_blocker);
>>>>>>> origin/dither2
}
}
@ -193,18 +173,11 @@ fn main() -> ! {
.product("Precursor")
.serial_number(&serial_number)
.build();
<<<<<<< HEAD
#[cfg(all(any(target_os = "none", target_os = "xous"), feature="emukbd"))]
{
let keyboard = composite.interface::<NKROBootKeyboardInterface<'_, _, _,>, _>();
keyboard.write_report(&Vec::<Keyboard>::new()).ok();
keyboard.tick().unwrap();
=======
#[cfg(any(target_os = "none", target_os = "xous"))]
{
keyboard.interface().write_report(&Vec::<Keyboard>::new()).ok();
keyboard.interface().tick().unwrap();
>>>>>>> origin/dither2
}
#[cfg(any(target_os = "none", target_os = "xous"))]
@ -266,7 +239,6 @@ fn main() -> ! {
}
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
let mut u2f_ipc = buffer.to_original::<U2fMsgIpc, _>().unwrap();
#[cfg(any(target_os = "none", target_os = "xous"))]
if fido_listener_pid == msg.sender.pid() {
let mut u2f_msg = RawFidoMsg::default();
assert_eq!(u2f_ipc.code, U2fCode::Tx, "Expected U2fCode::Tx in wrapper");
@ -280,8 +252,6 @@ fn main() -> ! {
} else {
u2f_ipc.code = U2fCode::Denied;
}
#[cfg(not(any(target_os = "none", target_os = "xous")))]
{u2f_ipc.code = U2fCode::Denied;}
buffer.replace(u2f_ipc).unwrap();
}
Some(Opcode::UsbIrqHandler) => {