diff options
author | Andreas Eversberg <jolly@eversberg.eu> | 2013-06-19 09:55:21 +0200 |
---|---|---|
committer | Andreas Eversberg <jolly@eversberg.eu> | 2013-06-19 15:16:58 +0200 |
commit | 8a8796802bc497f00b6a27ca14e2be0c9f9ec176 (patch) | |
tree | acc1cea7952769e426c8a063257e5936ce4923a6 /src/host | |
parent | f2ab5e14967426f4845b51def4d9105af22f9ad2 (diff) |
osmocon: Improve performance by handling several serial bytes at a time
Diffstat (limited to 'src/host')
-rw-r--r-- | src/host/osmocon/osmocon.c | 27 |
1 files changed, 19 insertions, 8 deletions
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) |