Browse Source

Merge branch 'master' into newscrypt

nfactor-troky
Con Kolivas 13 years ago
parent
commit
aca34d0aa1
  1. 16
      driver-bitforce.c
  2. 10
      fpgautils.c

16
driver-bitforce.c

@ -34,13 +34,15 @@ @@ -34,13 +34,15 @@
struct device_api bitforce_api;
#define BFopen(devpath) serial_open(devpath, 0, -1, true)
// Code must deal with a timeout
#define BFopen(devpath) serial_open(devpath, 0, 1, true)
static void BFgets(char *buf, size_t bufLen, int fd)
{
do
do {
buf[0] = '\0';
--bufLen;
while (likely(bufLen && read(fd, buf, 1) == 1 && (buf++)[0] != '\n'));
} while (likely(bufLen && read(fd, buf, 1) == 1 && (buf++)[0] != '\n'));
buf[0] = '\0';
}
@ -72,7 +74,7 @@ static bool bitforce_detect_one(const char *devpath) @@ -72,7 +74,7 @@ static bool bitforce_detect_one(const char *devpath)
BFwrite(fdDev, "ZGX", 3);
BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
if (unlikely(!pdevbuf[0])) {
applog(LOG_ERR, "BFL: Error reading (ZGX)");
applog(LOG_ERR, "BFL: Error reading/timeout (ZGX)");
return 0;
}
@ -200,7 +202,7 @@ void bitforce_init(struct cgpu_info *bitforce) @@ -200,7 +202,7 @@ void bitforce_init(struct cgpu_info *bitforce)
if (unlikely(!pdevbuf[0])) {
mutex_unlock(&bitforce->device_mutex);
applog(LOG_ERR, "BFL%i: Error reading (ZGX)", bitforce->device_id);
applog(LOG_ERR, "BFL%i: Error reading/timeout (ZGX)", bitforce->device_id);
return;
}
@ -240,7 +242,7 @@ static bool bitforce_get_temp(struct cgpu_info *bitforce) @@ -240,7 +242,7 @@ static bool bitforce_get_temp(struct cgpu_info *bitforce)
mutex_unlock(&bitforce->device_mutex);
if (unlikely(!pdevbuf[0])) {
applog(LOG_ERR, "BFL%i: Error: Get temp returned empty string", bitforce->device_id);
applog(LOG_ERR, "BFL%i: Error: Get temp returned empty string/timed out", bitforce->device_id);
bitforce->temp = 0;
return false;
}
@ -328,7 +330,7 @@ re_send: @@ -328,7 +330,7 @@ re_send:
}
if (unlikely(!pdevbuf[0])) {
applog(LOG_ERR, "BFL%i: Error: Send block data returned empty string", bitforce->device_id);
applog(LOG_ERR, "BFL%i: Error: Send block data returned empty string/timed out", bitforce->device_id);
return false;
}

10
fpgautils.c

@ -178,7 +178,8 @@ serial_open(const char*devpath, unsigned long baud, signed short timeout, bool p @@ -178,7 +178,8 @@ serial_open(const char*devpath, unsigned long baud, signed short timeout, bool p
SetCommConfig(hSerial, &comCfg, sizeof(comCfg));
const DWORD ctoms = (timeout == -1) ? 30000 : (timeout * 100);
// Code must specify a valid timeout value (0 means don't timeout)
const DWORD ctoms = (timeout * 100);
COMMTIMEOUTS cto = {ctoms, 0, ctoms, 0, ctoms};
SetCommTimeouts(hSerial, &cto);
@ -230,10 +231,9 @@ serial_open(const char*devpath, unsigned long baud, signed short timeout, bool p @@ -230,10 +231,9 @@ serial_open(const char*devpath, unsigned long baud, signed short timeout, bool p
my_termios.c_oflag &= ~OPOST;
my_termios.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
if (timeout >= 0) {
my_termios.c_cc[VTIME] = (cc_t)timeout;
my_termios.c_cc[VMIN] = 0;
}
// Code must specify a valid timeout value (0 means don't timeout)
my_termios.c_cc[VTIME] = (cc_t)timeout;
my_termios.c_cc[VMIN] = 0;
tcsetattr(fdDev, TCSANOW, &my_termios);
if (purge)

Loading…
Cancel
Save