Skip to content

Commit 4a189cd

Browse files
authored
Merge pull request #40 from rsahwe/master
Update port.rs to do \r\n
2 parents 53b7a1b + f7bda32 commit 4a189cd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/port.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,19 @@ impl SerialPort {
100100
}
101101

102102
/// Sends a byte on the serial port.
103+
/// 0x08 (backspace) and 0x7F (delete) get replaced with 0x08, 0x20, 0x08 and 0x0A (\n) gets replaced with \r\n.
104+
/// If this replacement is unwanted use [SerialPort::send_raw] instead.
103105
pub fn send(&mut self, data: u8) {
104106
match data {
105107
8 | 0x7F => {
106108
self.send_raw(8);
107109
self.send_raw(b' ');
108110
self.send_raw(8);
109111
}
112+
0x0A => {
113+
self.send_raw(0x0D);
114+
self.send_raw(0x0A);
115+
}
110116
data => {
111117
self.send_raw(data);
112118
}

0 commit comments

Comments
 (0)