From 8a8796802bc497f00b6a27ca14e2be0c9f9ec176 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Wed, 19 Jun 2013 09:55:21 +0200 Subject: osmocon: Improve performance by handling several serial bytes at a time --- src/host/osmocon/osmocon.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src/host/osmocon/osmocon.c') diff --git a/src/host/osmocon/osmocon.c b/src/host/osmocon/osmocon.c index 10662917..648d4164 100644 --- a/src/host/osmocon/osmocon.c +++ b/src/host/osmocon/osmocon.c @@ -655,13 +655,24 @@ static int handle_write_dnload(void) static int handle_sercomm_write(void) { - uint8_t c; + uint8_t buffer[256]; + int i, count = 0, end = 0; - if (sercomm_drv_pull(&c) != 0) { - if (write(dnload.serial_fd.fd, &c, 1) != 1) + for (i = 0; i < sizeof(buffer); i++) { + if (sercomm_drv_pull(&buffer[i]) == 0) { + end = 1; + break; + } + count++; + } + + if (count) { + if (write(dnload.serial_fd.fd, buffer, count) != count) perror("short write"); - } else - dnload.serial_fd.when &= ~BSC_FD_WRITE; + } + + if (end) + dnload.serial_fd.when &= ~BSC_FD_WRITE; return 0; } @@ -1154,13 +1165,13 @@ static int serial_read(struct osmo_fd *fd, unsigned int flags) if (flags & BSC_FD_READ) { switch (dnload.mode) { case MODE_ROMLOAD: - rc = handle_read_romload(); + while ((rc = handle_read_romload()) > 0); break; case MODE_MTK: - rc = handle_read_mtk(); + while ((rc = handle_read_mtk()) > 0); break; default: - rc = handle_read(); + while ((rc = handle_read()) > 0); break; } if (rc == 0) -- cgit v1.2.3