Browse Source

Merge branch 'bugfix_bf_timeout' into bfgminer

Conflicts:
	driver-modminer.c
Luke Dashjr 13 years ago
parent
commit
bfbe7cee1f
3 changed files with 10 additions and 5 deletions
  1. 2 2
      driver-bitforce.c
  2. 6 2
      fpgautils.c
  3. 2 1
      fpgautils.h

+ 2 - 2
driver-bitforce.c

@@ -47,7 +47,7 @@ enum {
 #define BITFORCE_SLEEP_MS 500
 #define BITFORCE_SLEEP_MS 500
 #define BITFORCE_TIMEOUT_S 7
 #define BITFORCE_TIMEOUT_S 7
 #define BITFORCE_TIMEOUT_MS (BITFORCE_TIMEOUT_S * 1000)
 #define BITFORCE_TIMEOUT_MS (BITFORCE_TIMEOUT_S * 1000)
-#define BITFORCE_LONG_TIMEOUT_S 15
+#define BITFORCE_LONG_TIMEOUT_S 25
 #define BITFORCE_LONG_TIMEOUT_MS (BITFORCE_LONG_TIMEOUT_S * 1000)
 #define BITFORCE_LONG_TIMEOUT_MS (BITFORCE_LONG_TIMEOUT_S * 1000)
 #define BITFORCE_CHECK_INTERVAL_MS 10
 #define BITFORCE_CHECK_INTERVAL_MS 10
 #define WORK_CHECK_INTERVAL_MS 50
 #define WORK_CHECK_INTERVAL_MS 50
@@ -61,7 +61,7 @@ enum {
 struct device_api bitforce_api;
 struct device_api bitforce_api;
 
 
 // Code must deal with a timeout
 // Code must deal with a timeout
-#define BFopen(devpath)  serial_open(devpath, 0, 300, true)
+#define BFopen(devpath)  serial_open(devpath, 0, 250, true)
 
 
 static void BFgets(char *buf, size_t bufLen, int fd)
 static void BFgets(char *buf, size_t bufLen, int fd)
 {
 {

+ 6 - 2
fpgautils.c

@@ -10,6 +10,7 @@
 
 
 #include "config.h"
 #include "config.h"
 
 
+#include <stdint.h>
 #include <sys/types.h>
 #include <sys/types.h>
 #include <dirent.h>
 #include <dirent.h>
 #include <string.h>
 #include <string.h>
@@ -143,8 +144,11 @@ _serial_detect(const char*dname, detectone_func_t detectone, autoscan_func_t aut
 	return found;
 	return found;
 }
 }
 
 
+/* NOTE: Linux only supports uint8_t (decisecond) timeouts; limiting it in
+ *       this interface buys us warnings when bad constants are passed in.
+ */
 int
 int
-serial_open(const char*devpath, unsigned long baud, signed short timeout, bool purge)
+serial_open(const char*devpath, unsigned long baud, uint8_t timeout, bool purge)
 {
 {
 #ifdef WIN32
 #ifdef WIN32
 	HANDLE hSerial = CreateFile(devpath, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
 	HANDLE hSerial = CreateFile(devpath, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
@@ -179,7 +183,7 @@ serial_open(const char*devpath, unsigned long baud, signed short timeout, bool p
 	SetCommConfig(hSerial, &comCfg, sizeof(comCfg));
 	SetCommConfig(hSerial, &comCfg, sizeof(comCfg));
 
 
 	// Code must specify a valid timeout value (0 means don't timeout)
 	// Code must specify a valid timeout value (0 means don't timeout)
-	const DWORD ctoms = (timeout * 100);
+	const DWORD ctoms = ((DWORD)timeout * 100);
 	COMMTIMEOUTS cto = {ctoms, 0, ctoms, 0, ctoms};
 	COMMTIMEOUTS cto = {ctoms, 0, ctoms, 0, ctoms};
 	SetCommTimeouts(hSerial, &cto);
 	SetCommTimeouts(hSerial, &cto);
 
 

+ 2 - 1
fpgautils.h

@@ -11,6 +11,7 @@
 #define FPGAUTILS_H
 #define FPGAUTILS_H
 
 
 #include <stdbool.h>
 #include <stdbool.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdio.h>
 
 
 typedef bool(*detectone_func_t)(const char*);
 typedef bool(*detectone_func_t)(const char*);
@@ -26,7 +27,7 @@ extern int _serial_detect(const char*dname, detectone_func_t, autoscan_func_t, b
 extern int serial_autodetect_devserial(detectone_func_t, const char*prodname);
 extern int serial_autodetect_devserial(detectone_func_t, const char*prodname);
 extern int serial_autodetect_udev     (detectone_func_t, const char*prodname);
 extern int serial_autodetect_udev     (detectone_func_t, const char*prodname);
 
 
-extern int serial_open(const char*devpath, unsigned long baud, signed short timeout, bool purge);
+extern int serial_open(const char*devpath, unsigned long baud, uint8_t timeout, bool purge);
 extern ssize_t _serial_read(int fd, char *buf, size_t buflen, char*eol);
 extern ssize_t _serial_read(int fd, char *buf, size_t buflen, char*eol);
 #define serial_read(fd, buf, count)  \
 #define serial_read(fd, buf, count)  \
 	_serial_read(fd, (char*)(buf), count, NULL)
 	_serial_read(fd, (char*)(buf), count, NULL)