From 183f8b94029b3ba361daeabde03241b5947f29b9 Mon Sep 17 00:00:00 2001 From: WillianChan Date: Mon, 14 Sep 2020 15:25:33 +0800 Subject: [PATCH 1/3] [drivers/serial]add a line feed to the carriage return character when using interrupt tx Signed-off-by: WillianChan --- components/drivers/serial/serial.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c index d1c04dec6f..19c499258a 100644 --- a/components/drivers/serial/serial.c +++ b/components/drivers/serial/serial.c @@ -22,6 +22,8 @@ * 2017-11-15 JasonJia fix poll rx issue when data is full. * add TCFLSH and FIONREAD support. * 2018-12-08 Ernest Chen add DMA choice + * 2020-09-14 WillianChan add a line feed to the carriage return character + when using interrupt tx */ #include @@ -315,6 +317,18 @@ rt_inline int _serial_int_tx(struct rt_serial_device *serial, const rt_uint8_t * while (length) { + /* + * to be polite with serial console add a line feed + * to the carriage return character + */ + if (*data == '\n' && (serial->parent.open_flag & RT_DEVICE_FLAG_STREAM)) + { + if (serial->ops->putc(serial, '\r') == -1) + { + rt_completion_wait(&(tx->completion), RT_WAITING_FOREVER); + continue; + } + if (serial->ops->putc(serial, *(char*)data) == -1) { rt_completion_wait(&(tx->completion), RT_WAITING_FOREVER); From c6b4c2ea2b42711be7958cc640ded1024366fb36 Mon Sep 17 00:00:00 2001 From: WillianChan Date: Mon, 14 Sep 2020 17:20:27 +0800 Subject: [PATCH 2/3] [drivers/serial]modify annotation Signed-off-by: WillianChan --- components/drivers/serial/serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c index 19c499258a..65c6c46f2c 100644 --- a/components/drivers/serial/serial.c +++ b/components/drivers/serial/serial.c @@ -23,7 +23,7 @@ * add TCFLSH and FIONREAD support. * 2018-12-08 Ernest Chen add DMA choice * 2020-09-14 WillianChan add a line feed to the carriage return character - when using interrupt tx + * when using interrupt tx */ #include From ee3d05f5833440caf8c105a6951541916600f21d Mon Sep 17 00:00:00 2001 From: WillianChan Date: Mon, 14 Sep 2020 18:16:32 +0800 Subject: [PATCH 3/3] [drivers/serial]resolve compile error Signed-off-by: WillianChan --- components/drivers/serial/serial.c | 1 + 1 file changed, 1 insertion(+) diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c index 65c6c46f2c..ad837a6564 100644 --- a/components/drivers/serial/serial.c +++ b/components/drivers/serial/serial.c @@ -328,6 +328,7 @@ rt_inline int _serial_int_tx(struct rt_serial_device *serial, const rt_uint8_t * rt_completion_wait(&(tx->completion), RT_WAITING_FOREVER); continue; } + } if (serial->ops->putc(serial, *(char*)data) == -1) {