From 2ffcd1daecf8875f63c7f6349496841d20896da1 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Thu, 5 Oct 2023 08:40:18 +0200 Subject: [PATCH 1/2] code cleanup --- src/main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index ad1eb45..ebbfb4a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,4 @@ use chrono::{DateTime, Duration, Local}; -use core::num; use log::debug; use std::{collections::HashMap, net::UdpSocket, thread}; From 5d15a2b56bf877d8c8c4a8c533aa801a89aaef9b Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Thu, 5 Oct 2023 08:43:03 +0200 Subject: [PATCH 2/2] comment added --- src/main.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.rs b/src/main.rs index ebbfb4a..4a91456 100644 --- a/src/main.rs +++ b/src/main.rs @@ -88,6 +88,7 @@ fn mopp(speed: u8, data: &[u8]) -> Vec { m.replace_range(m.len() - 2.., "11"); // EOW + // Extend to full bytes m = format!( "{1:0<0$}", (8 as f32 * (m.len() as f32 / 8 as f32).ceil()) as usize, @@ -96,6 +97,7 @@ fn mopp(speed: u8, data: &[u8]) -> Vec { let mut res = Vec::::new(); + // Convert string representation to "real" bits for i in (0..m.len()).step_by(8) { let value = u8::from_str_radix(&m[i..i + 8], 2).unwrap(); res.push(value);