Skip to content

Commit

Permalink
Merge pull request #474 from ChocolateLoverRaj/crlf-serial
Browse files Browse the repository at this point in the history
Convert LF to CRLF when writing to serial port
  • Loading branch information
Freax13 authored Nov 22, 2024
2 parents af99f0f + 0688aee commit ea2529b
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 ea2529b

Please sign in to comment.