Git
Wiki
Site
projects
/
soft
/
tools
/
lpctools
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
b042031
)
Added timeout (fixed, 500ms) to read commands
author
Nathael Pajani
<nathael.pajani@ed3l.fr>
Mon, 14 May 2012 23:21:32 +0000
(
01:21
+0200)
committer
Nathael Pajani
<nathael.pajani@ed3l.fr>
Mon, 14 May 2012 23:21:32 +0000
(
01:21
+0200)
isp_utils.c
patch
|
blob
|
history
diff --git
a/isp_utils.c
b/isp_utils.c
index
af702d9
..
950fd95
100644
(file)
--- a/
isp_utils.c
+++ b/
isp_utils.c
@@
-148,6
+148,7
@@
int isp_serial_read(char* buf, unsigned int buf_size, unsigned int min_read)
{
int nb = 0;
unsigned int count = 0;
+ unsigned int loops = 0; /* Used to create a timeout */
if (min_read > buf_size) {
printf("serial_read: buffer too small for min read value.\n");
@@
-158,6
+159,9
@@
int isp_serial_read(char* buf, unsigned int buf_size, unsigned int min_read)
nb = read(serial_fd, &buf[count], (buf_size - count));
if (nb < 0) {
if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) {
+ if (loops++ > 100) {
+ break; /* timeout at 500ms */
+ }
usleep( 5000 );
continue;
}
Techno-Innov
42 impasse de la Combe du Bois
01150 Blyes - France
contact@techno-innov.fr
Design et hébergement du site :
Techno-Innov
Techno-Innov
- SARL Coopérative
539 169 417 RCS Bourg-en-Bresse
Ce site n'utilise pas de cookies, désolé pour les gourmands !