|
3 | 3 | /// @ingroup ports |
4 | 4 | /// @cond |
5 | 5 | ///*************************************************************************** |
6 | | -/// Last updated for version 6.8.0 |
7 | | -/// Last updated on 2020-03-31 |
| 6 | +/// Last updated for version 6.9.2 |
| 7 | +/// Last updated on 2021-01-14 |
8 | 8 | /// |
9 | 9 | /// Q u a n t u m L e a P s |
10 | 10 | /// ------------------------ |
11 | 11 | /// Modern Embedded Software |
12 | 12 | /// |
13 | | -/// Copyright (C) 2005-2020 Quantum Leaps. All rights reserved. |
| 13 | +/// Copyright (C) 2005-2021 Quantum Leaps. All rights reserved. |
14 | 14 | /// |
15 | 15 | /// This program is open source software: you can redistribute it and/or |
16 | 16 | /// modify it under the terms of the GNU General Public License as published |
@@ -261,29 +261,21 @@ void QS::onTestLoop() { |
261 | 261 | struct timeval timeout = { |
262 | 262 | (long)0, (long)(QS_TIMEOUT_MS * 1000) |
263 | 263 | }; |
264 | | - int nrec = select(l_sock + 1, &readSet, |
| 264 | + int status = select(l_sock + 1, &readSet, |
265 | 265 | (fd_set *)0, (fd_set *)0, &timeout); |
266 | | - if (nrec < 0) { |
| 266 | + if (status < 0) { |
267 | 267 | FPRINTF_S(stderr, "<TARGET> ERROR socket select,errno=%d\n", |
268 | 268 | errno); |
269 | 269 | onCleanup(); |
270 | 270 | exit(-2); |
271 | 271 | } |
272 | | - else if ((nrec > 0) && FD_ISSET(l_sock, &readSet)) { // socket ready? |
273 | | - uint8_t buf[QS_RX_SIZE]; |
274 | | - int status = recv(l_sock, (char *)buf, (int)sizeof(buf), 0); |
275 | | - while (status > 0) { // any data received? |
276 | | - uint8_t *pb; |
277 | | - int i = (int)rxGetNfree(); |
278 | | - if (i > status) { |
279 | | - i = status; |
280 | | - } |
281 | | - status -= i; |
282 | | - // reorder the received bytes into QS-RX buffer |
283 | | - for (pb = &buf[0]; i > 0; --i, ++pb) { |
284 | | - rxPut(*pb); |
285 | | - } |
286 | | - rxParse(); // parse all n-bytes of data |
| 272 | + else if ((status > 0) && FD_ISSET(l_sock, &readSet)) { //socket ready? |
| 273 | + status = recv(l_sock, |
| 274 | + (char *)QS::rxPriv_.buf, (int)QS::rxPriv_.end, 0); |
| 275 | + if (status > 0) { // any data received? |
| 276 | + QS::rxPriv_.tail = 0U; |
| 277 | + QS::rxPriv_.head = status; // # bytes received |
| 278 | + QS::rxParse(); // parse all received bytes |
287 | 279 | } |
288 | 280 | } |
289 | 281 |
|
|
0 commit comments