summaryrefslogtreecommitdiff
path: root/libaltos/libaltos.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-04-11 22:16:03 -0700
committerKeith Packard <keithp@keithp.com>2013-04-12 16:37:49 -0700
commit25c01719f17be8da73a859867c14df0fc29b5441 (patch)
tree11c64017b963768dcc281c239f691b79d2fd5d9d /libaltos/libaltos.c
parent679401fff981b675dd5a188c64e8940254588800 (diff)
libaltos: Retry Windows serial port open five times
Maybe this helps? Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'libaltos/libaltos.c')
-rw-r--r--libaltos/libaltos.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libaltos/libaltos.c b/libaltos/libaltos.c
index 2a41ef80..ad03e638 100644
--- a/libaltos/libaltos.c
+++ b/libaltos/libaltos.c
@@ -1319,6 +1319,7 @@ altos_open(struct altos_device *device)
struct altos_file *file = calloc (1, sizeof (struct altos_file));
char full_name[64];
COMMTIMEOUTS timeouts;
+ int i;
if (!file)
return NULL;
@@ -1326,7 +1327,15 @@ altos_open(struct altos_device *device)
strcpy(full_name, "\\\\.\\");
strcat(full_name, device->path);
- file->handle = open_serial(full_name);
+ file->handle = INVALID_HANDLE_VALUE;
+
+ for (i = 0; i < 5; i++) {
+ file->handle = open_serial(full_name);
+ if (file->handle != INVALID_HANDLE_VALUE)
+ break;
+ Sleep(100);
+ }
+
if (file->handle == INVALID_HANDLE_VALUE) {
free(file);
return NULL;