Replace \n to \r\n in serial driver

Signed-off-by: Harry Chen <i@harrychen.xyz>
master
Harry Chen 6 years ago
parent 324b64c2ed
commit 75b67fa575

@ -68,12 +68,19 @@ impl SerialPort {
impl Write for SerialPort {
fn write_str(&mut self, s: &str) -> Result {
for c in s.bytes() {
if c == 127 {
self.putchar(8);
self.putchar(b' ');
self.putchar(8);
} else {
self.putchar(c);
match c {
127 => {
self.putchar(8);
self.putchar(b' ');
self.putchar(8);
},
b'\n' => {
self.putchar(b'\r');
self.putchar(b'\n');
},
c => {
self.putchar(c);
}
}
}
Ok(())

@ -59,12 +59,19 @@ impl SerialPort {
impl Write for SerialPort {
fn write_str(&mut self, s: &str) -> Result {
for c in s.bytes() {
if c == 127 {
self.putchar(8);
self.putchar(b' ');
self.putchar(8);
} else {
self.putchar(c);
match c {
127 => {
self.putchar(8);
self.putchar(b' ');
self.putchar(8);
},
b'\n' => {
self.putchar(b'\r');
self.putchar(b'\n');
},
c => {
self.putchar(c);
}
}
}
Ok(())

@ -68,12 +68,19 @@ impl SerialPort {
impl Write for SerialPort {
fn write_str(&mut self, s: &str) -> Result {
for c in s.bytes() {
if c == 127 {
self.putchar(8);
self.putchar(b' ');
self.putchar(8);
} else {
self.putchar(c);
match c {
127 => {
self.putchar(8);
self.putchar(b' ');
self.putchar(8);
},
b'\n' => {
self.putchar(b'\r');
self.putchar(b'\n');
},
c => {
self.putchar(c);
}
}
}
Ok(())

Loading…
Cancel
Save