Browse Source

Merge pull request #162 from luke-jr/workaround_icarus_uart_issue

Workaround Icarus UART failures by reopening the tty every scanhash
nfactor-troky
Con Kolivas 13 years ago
parent
commit
98c0b297b8
  1. 24
      driver-icarus.c

24
driver-icarus.c

@ -257,15 +257,6 @@ static bool icarus_prepare(struct thr_info *thr)
struct timeval now; struct timeval now;
int fd = icarus_open(icarus->device_path);
if (unlikely(-1 == fd)) {
applog(LOG_ERR, "Failed to open Icarus on %s",
icarus->device_path);
return false;
}
icarus->device_fd = fd;
applog(LOG_INFO, "Opened Icarus on %s", icarus->device_path); applog(LOG_INFO, "Opened Icarus on %s", icarus->device_path);
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
get_datestamp(icarus->init, &now); get_datestamp(icarus->init, &now);
@ -289,7 +280,13 @@ static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work,
struct timeval tv_start, tv_end, diff; struct timeval tv_start, tv_end, diff;
icarus = thr->cgpu; icarus = thr->cgpu;
fd = icarus->device_fd;
fd = icarus_open(icarus->device_path);
if (unlikely(-1 == fd)) {
applog(LOG_ERR, "Failed to open Icarus on %s",
icarus->device_path);
return 0;
}
memset(ob_bin, 0, sizeof(ob_bin)); memset(ob_bin, 0, sizeof(ob_bin));
memcpy(ob_bin, work->midstate, 32); memcpy(ob_bin, work->midstate, 32);
@ -303,8 +300,10 @@ static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work,
gettimeofday(&tv_start, NULL); gettimeofday(&tv_start, NULL);
ret = icarus_write(fd, ob_bin, sizeof(ob_bin)); ret = icarus_write(fd, ob_bin, sizeof(ob_bin));
if (ret) if (ret) {
icarus_close(fd);
return 0; /* This should never happen */ return 0; /* This should never happen */
}
ob_hex = bin2hex(ob_bin, sizeof(ob_bin)); ob_hex = bin2hex(ob_bin, sizeof(ob_bin));
if (ob_hex) { if (ob_hex) {
@ -330,6 +329,7 @@ static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work,
memcpy((char *)&nonce, nonce_bin, sizeof(nonce_bin)); memcpy((char *)&nonce, nonce_bin, sizeof(nonce_bin));
work->blk.nonce = 0xffffffff; work->blk.nonce = 0xffffffff;
icarus_close(fd);
if (nonce == 0 && ret) { if (nonce == 0 && ret) {
if (unlikely(diff.tv_sec > 12 || (diff.tv_sec == 11 && diff.tv_usec > 300067))) if (unlikely(diff.tv_sec > 12 || (diff.tv_sec == 11 && diff.tv_usec > 300067)))
@ -370,8 +370,6 @@ static void icarus_shutdown(struct thr_info *thr)
if (icarus->device_path) if (icarus->device_path)
free(icarus->device_path); free(icarus->device_path);
close(icarus->device_fd);
devices[icarus->device_id] = NULL; devices[icarus->device_id] = NULL;
free(icarus); free(icarus);

Loading…
Cancel
Save