blob: 4e13363ddd9a5b47077657f4d907cfb5edf86b00 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
From 8a8796802bc497f00b6a27ca14e2be0c9f9ec176 Mon Sep 17 00:00:00 2001
From: Andreas Eversberg <jolly@eversberg.eu>
Date: Wed, 19 Jun 2013 07:55:21 +0000
Subject: osmocon: Improve performance by handling several serial bytes at a time
---
diff --git a/src/host/osmocon/osmocon.c b/src/host/osmocon/osmocon.c
index 1066291..648d416 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 v0.9.1
|