Vendor Command + HID fix (#618)
* Fixes CBOR message passing through Vendor HID I did all my tests on hardware with this fix, and now I'm surprised that it didn't end up on develop. So should have been part of a former PR. * vendor channel test * forward vendor HID correctly for upgrades * fixes cargo fmt * removes script and updates documentation to match
This commit is contained in:
15
src/env/tock/commands.rs
vendored
15
src/env/tock/commands.rs
vendored
@@ -44,7 +44,7 @@ pub fn process_vendor_command(
|
||||
channel: Channel,
|
||||
) -> Option<Vec<u8>> {
|
||||
#[cfg(feature = "vendor_hid")]
|
||||
if matches!(channel, Channel::VendorHid(_)) {
|
||||
if matches!(channel, Channel::MainHid(_)) {
|
||||
return None;
|
||||
}
|
||||
process_cbor(env, bytes, channel).unwrap_or_else(|e| Some(vec![e as u8]))
|
||||
@@ -290,6 +290,8 @@ mod test {
|
||||
use cbor::cbor_map;
|
||||
|
||||
const DUMMY_CHANNEL: Channel = Channel::MainHid([0x12, 0x34, 0x56, 0x78]);
|
||||
#[cfg(feature = "vendor_hid")]
|
||||
const VENDOR_CHANNEL: Channel = Channel::VendorHid([0x12, 0x34, 0x56, 0x78]);
|
||||
|
||||
#[test]
|
||||
fn test_process_cbor_unrelated_input() {
|
||||
@@ -317,6 +319,17 @@ mod test {
|
||||
.is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "vendor_hid")]
|
||||
fn test_process_command_valid_vendor_hid() {
|
||||
let mut env = TockEnv::default();
|
||||
let cbor_bytes = vec![VENDOR_COMMAND_UPGRADE_INFO];
|
||||
assert!(process_cbor(&mut env, &cbor_bytes, VENDOR_CHANNEL)
|
||||
.unwrap()
|
||||
.is_some());
|
||||
assert!(process_vendor_command(&mut env, &cbor_bytes, VENDOR_CHANNEL).is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_vendor_configure_parameters() {
|
||||
let dummy_cert = [0xddu8; 20];
|
||||
|
||||
Reference in New Issue
Block a user