From 068280f575bf70a2c72cb042a81f7fc57bc94ac2 Mon Sep 17 00:00:00 2001
From: Federico Lolli <federico.lolli@skywarder.eu>
Date: Mon, 19 Feb 2024 15:51:16 +0100
Subject: [PATCH] fix float amount of bytes needed

---
 src/lib.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/lib.rs b/src/lib.rs
index af106ff..67cbfda 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -140,9 +140,9 @@ fn read_from_serial(mut outputs: Output<'_>, args: Args<'_>) -> SResult<()> {
     let n_doubles = arg as usize;
 
     // Read n_doubles from the serial port
-    let bytes = SERIAL.read().unwrap().read_n_bytes(&port, n_doubles * 8)?;
+    let bytes = SERIAL.read().read_n_bytes(&port, n_doubles * 4)?;
     let doubles = bytes
-        .chunks_exact(8)
+        .chunks_exact(4)
         .map(|chunk| f32::from_be_bytes(chunk.try_into().unwrap()))
         .collect::<Vec<f32>>();
     warn_debug!("Read {} bytes from serial port", n_doubles);
-- 
GitLab