From c9391cd638a6811b05ed70ceb08b84bac6d85e05 Mon Sep 17 00:00:00 2001 From: Benno Rice Date: Sat, 13 Mar 2021 22:30:13 +1100 Subject: [PATCH 1/2] Fix parameter length calculations. --- src/params.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/params.rs b/src/params.rs index 2acc7e1..f733b61 100644 --- a/src/params.rs +++ b/src/params.rs @@ -4,7 +4,7 @@ use crate::param::SendParam; pub trait SendParams { fn len(&self, long: bool) -> usize { - self.param_len(long) + if long { 2 } else { 1 } + self.param_len(long) + 1 } fn param_len(&self, long: bool) -> usize; From 8ff06dbe8c6275264ec885955e8beb6111ef0687 Mon Sep 17 00:00:00 2001 From: Benno Rice Date: Sun, 14 Mar 2021 13:22:43 +1100 Subject: [PATCH 2/2] Use same padding byte value as the Arduino library. --- src/transport/spi.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transport/spi.rs b/src/transport/spi.rs index 41db49b..b3bdd57 100644 --- a/src/transport/spi.rs +++ b/src/transport/spi.rs @@ -81,7 +81,7 @@ where // Pad to 4 byte boundary let mut total_len = send_params.len(long_send) + 3; while 0 != total_len % 4 { - Self::send_byte(spi, 0)?; + Self::send_byte(spi, 0xff)?; total_len += 1; }