Skip to content

Commit

Permalink
Convert LF to CRLF when writing to serial port
Browse files Browse the repository at this point in the history
  • Loading branch information
ChocolateLoverRaj committed Nov 17, 2024
1 parent af99f0f commit 0688aee
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion common/src/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
}

0 comments on commit 0688aee

Please sign in to comment.