[nuttx-bb][PATCH 1/3] Fix console by sending chunk blocks lesser than 32 bytes

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/baseband-devel@lists.osmocom.org/.

Denis 'GNUtoo' Carikli GNUtoo at no-log.org
Sat Feb 25 20:34:41 UTC 2012


From: Alan Carvalho de Assis <acassis at gmail.com>

We cannot send a big chunk of bytes to sercomm_puts because .txready
on NuttX doesn't detect when "UART" finished sending data, then data
are lost. An work-around to fix it is sending less bytes and putting
a delay after each transfer.

Signed-off-by: Alan Carvalho de Assis <acassis at gmail.com>
---
 nuttx/drivers/sercomm/console.c |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/nuttx/drivers/sercomm/console.c b/nuttx/drivers/sercomm/console.c
index 09ce469..1b96acf 100644
--- a/nuttx/drivers/sercomm/console.c
+++ b/nuttx/drivers/sercomm/console.c
@@ -106,14 +106,27 @@ static ssize_t sc_console_read(file_t *filep, FAR char *buffer, size_t buflen)
 }
 
 /* XXX: redirect to old Osmocom-BB comm/sercomm_cons.c -> 2 buffers */
-extern int sercomm_write(void *file, const char *s, const int len);
+extern int sercomm_puts(const char *s);
 static ssize_t sc_console_write(file_t *filep, FAR const char *buffer, size_t buflen)
 {
-	int ret = sercomm_write(filep, buffer, buflen);
-	if(ret < 0)
-  		return ret;
+	int i, cnt;
+	char dstbuf[32];
+
+	if (buflen >= 31)
+		cnt = 31;
 	else
-  		return buflen;
+		cnt = buflen;
+
+        memcpy(dstbuf, buffer, cnt);
+        dstbuf[cnt] = '\0';
+
+	/* print part of our buffer */
+	sercomm_puts(dstbuf);
+
+	/* wait a little bit to get data transfered */
+	up_mdelay(1);
+
+	return cnt;
 }
 
 /* Forward ioctl to uart driver */
-- 
1.7.4.1





More information about the baseband-devel mailing list