diff --git a/semestralka_1_final_crate/software_uart/src/uart_emulation.rs b/semestralka_1_final_crate/software_uart/src/uart_emulation.rs index 5c65314..7875b38 100644 --- a/semestralka_1_final_crate/software_uart/src/uart_emulation.rs +++ b/semestralka_1_final_crate/software_uart/src/uart_emulation.rs @@ -116,25 +116,9 @@ pub fn decode_uart_samples( let frame_bits = 1 + nbits + parity_bits + stop_bits_count; let frame_len = frame_bits * ovs; - // Majority vote over 3 samples centered at `i` + // Get sample in the middle of the bit let get_bit = |i: usize| -> u8 { - let mut votes = 0; - // Check i-1, i, i+1. Saturating sub/add handles boundaries roughly. - if i > 0 && samples.get(i - 1).map_or(true, |&x| x != 0) { - votes += 1; - } - if samples.get(i).map_or(true, |&x| x != 0) { - votes += 1; - } - if samples.get(i + 1).map_or(true, |&x| x != 0) { - votes += 1; - } - - if votes >= 2 { - 1 - } else { - 0 - } + if samples[i] != 0 { 1 } else { 0 } }; // Decode while remaining samples for a full frame