From da2c29b98eef1e2c805797d19ece797fc8fcf845 Mon Sep 17 00:00:00 2001 From: Michael Shepanski Date: Mon, 26 Jan 2026 15:46:39 -0500 Subject: [PATCH 1/2] Fix data extraction in run_tap_command to handle potential length/status byte in response --- src/protocol.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/protocol.rs b/src/protocol.rs index 9ad1a10..b98006e 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -171,7 +171,15 @@ pub fn run_tap_command(device: &HidDevice, tap_bytes: &[u8]) -> Result 0x7E { + 1 // Skip non-printable length/status byte + } else { + 0 // Data starts immediately + }; + let result = response_report[data_start..].split(|&x| x == 0).next().unwrap(); Ok(std::str::from_utf8(result) .map_err(|e| Error::ProtocolError(e.into()))? From d7a934948edaff5645a771a94f01e33c3f33fa44 Mon Sep 17 00:00:00 2001 From: Michael Shepanski Date: Mon, 26 Jan 2026 17:02:17 -0500 Subject: [PATCH 2/2] FIx formatting. --- src/protocol.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/protocol.rs b/src/protocol.rs index b98006e..3db8c50 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -175,11 +175,14 @@ pub fn run_tap_command(device: &HidDevice, tap_bytes: &[u8]) -> Result 0x7E { - 1 // Skip non-printable length/status byte + 1 // Skip non-printable length/status byte } else { - 0 // Data starts immediately + 0 // Data starts immediately }; - let result = response_report[data_start..].split(|&x| x == 0).next().unwrap(); + let result = response_report[data_start..] + .split(|&x| x == 0) + .next() + .unwrap(); Ok(std::str::from_utf8(result) .map_err(|e| Error::ProtocolError(e.into()))?