From 0688aeeadcc8b98a6a5765f4f1b126588aedffb9 Mon Sep 17 00:00:00 2001 From: Rajas Paranjpe <52586855+ChocolateLoverRaj@users.noreply.github.com> Date: Sun, 17 Nov 2024 11:25:40 -0800 Subject: [PATCH] Convert LF to CRLF when writing to serial port --- common/src/serial.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/common/src/serial.rs b/common/src/serial.rs index 1882e366..8435c8e1 100644 --- a/common/src/serial.rs +++ b/common/src/serial.rs @@ -17,7 +17,12 @@ impl SerialPort { impl fmt::Write for SerialPort { fn write_str(&mut self, s: &str) -> fmt::Result { - self.port.write_str(s).unwrap(); + for char in s.bytes() { + match char { + b'\n' => self.port.write_str("\r\n").unwrap(), + byte => self.port.send(byte), + } + } Ok(()) } }