Skip to content

Commit d44b57d

Browse files
committed
Fix windows driver
Signed-off-by: Daniel Schaefer <[email protected]>
1 parent a929fbc commit d44b57d

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

framework_lib/src/ccgx/device.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ impl PdController {
232232
pub fn get_silicon_id(&self) -> EcResult<u16> {
233233
let data = self.ccgx_read(ControlRegisters::SiliconId, 2)?;
234234
assert!(data.len() >= 2);
235-
debug_assert_eq!(data.len(), 2);
235+
// TODO: The Windows driver seems to return 20 more bytes than expected
236+
//debug_assert_eq!(data.len(), 2);
236237
Ok(u16::from_le_bytes([data[0], data[1]]))
237238
}
238239

framework_lib/src/chromium_ec/command.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,10 @@ pub trait EcRequestRaw<R> {
136136
Self: Sized,
137137
{
138138
let response = self.send_command_vec_extra(ec, extra_data)?;
139-
if response.len() != std::mem::size_of::<R>() {
139+
// TODO: The Windows driver seems to return 20 more bytes than expected
140+
if response.len() < std::mem::size_of::<R>() {
140141
return Err(EcError::DeviceError(format!(
141-
"Returned data is not the expected ({}) size: {}",
142+
"Returned data size ({}) is less than expected ({})",
142143
response.len(),
143144
std::mem::size_of::<R>()
144145
)));

framework_lib/src/chromium_ec/windows.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ pub fn send_command(command: u16, command_version: u8, data: &[u8]) -> EcResult<
112112
Some(status) => return Err(EcError::Response(status)),
113113
}
114114

115-
let out_buffer = &cmd.buffer[..(returned as usize)];
115+
// TODO: Figure out why that's sometimes bigger
116+
let end = std::cmp::min(returned, 256);
117+
118+
let out_buffer = &cmd.buffer[..(end as usize)];
116119
Ok(out_buffer.to_vec())
117120
}
118121

0 commit comments

Comments
 (0)