Commit 33b0aa38117cb110cf91d10d66e4416dabd09846

Con Kolivas 2012-02-15T02:26:44

Merge pull request #117 from luke-jr/bitforce_win32_timeout_set bitforce: Set a 30 second timeout for serial port on Windows, since the default is undefined

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/bitforce.c b/bitforce.c
index efa4c20..d868a64 100644
--- a/bitforce.c
+++ b/bitforce.c
@@ -40,6 +40,10 @@ static int BFopen(const char *devpath)
 	HANDLE hSerial = CreateFile(devpath, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
 	if (unlikely(hSerial == INVALID_HANDLE_VALUE))
 		return -1;
+	
+	COMMTIMEOUTS cto = {30000, 0, 30000, 0, 30000};
+	SetCommTimeouts(hSerial, &cto);
+	
 	return _open_osfhandle((LONG)hSerial, 0);
 }