Browse Source

Use the avalon read timeout to completion if no data has been read.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
2a222ecffa
  1. 22
      driver-avalon.c
  2. 1
      driver-avalon.h

22
driver-avalon.c

@ -242,13 +242,14 @@ static void wait_avalon_ready(struct cgpu_info *avalon)
} }
} }
static int avalon_read(struct cgpu_info *avalon, unsigned char *buf, size_t bufsize) static int avalon_read(struct cgpu_info *avalon, unsigned char *buf,
size_t bufsize, int timeout)
{ {
struct cg_usb_device *usbdev = avalon->usbdev; struct cg_usb_device *usbdev = avalon->usbdev;
int err, amount; int err, amount;
err = libusb_bulk_transfer(usbdev->handle, usbdev->found->eps[DEFAULT_EP_IN].ep, err = libusb_bulk_transfer(usbdev->handle, usbdev->found->eps[DEFAULT_EP_IN].ep,
buf, bufsize, &amount, AVALON_READ_TIMEOUT); buf, bufsize, &amount, timeout);
applog(LOG_DEBUG, "%s%i: Get avalon read got err %d", applog(LOG_DEBUG, "%s%i: Get avalon read got err %d",
avalon->drv->name, avalon->device_id, err); avalon->drv->name, avalon->device_id, err);
return amount; return amount;
@ -281,7 +282,8 @@ static int avalon_reset(struct cgpu_info *avalon, bool initial)
return 0; return 0;
} }
ret = avalon_read(avalon, (unsigned char *)&ar, AVALON_READ_SIZE); ret = avalon_read(avalon, (unsigned char *)&ar, AVALON_READ_SIZE,
AVALON_RESET_TIMEOUT);
/* What do these sleeps do?? */ /* What do these sleeps do?? */
p.tv_sec = 0; p.tv_sec = 0;
@ -742,6 +744,7 @@ static void *avalon_get_results(void *userdata)
RenameThread(threadname); RenameThread(threadname);
while (42) { while (42) {
struct timeval tv_start, now, tdiff;
unsigned char buf[rsize]; unsigned char buf[rsize];
int amount, ofs, cp; int amount, ofs, cp;
@ -754,10 +757,19 @@ static void *avalon_get_results(void *userdata)
offset = 0; offset = 0;
} }
amount = avalon_read(avalon, buf, rsize); cgtime(&tv_start);
amount = avalon_read(avalon, buf, rsize, AVALON_READ_TIMEOUT);
if (amount < 3) if (amount < 3) {
int ms_delay;
cgtime(&now);
timersub(&now, &tv_start, &tdiff);
ms_delay = AVALON_READ_TIMEOUT - (tdiff.tv_usec / 1000);
if (ms_delay > 0)
nmsleep(ms_delay);
continue; continue;
}
if (opt_debug) { if (opt_debug) {
applog(LOG_DEBUG, "Avalon: get:"); applog(LOG_DEBUG, "Avalon: get:");

1
driver-avalon.h

@ -30,6 +30,7 @@
#define AVALON_FTDI_READSIZE 512 #define AVALON_FTDI_READSIZE 512
#define AVALON_READBUF_SIZE 8192 #define AVALON_READBUF_SIZE 8192
#define AVALON_RESET_TIMEOUT 100
#define AVALON_READ_TIMEOUT 10 #define AVALON_READ_TIMEOUT 10
struct avalon_task { struct avalon_task {

Loading…
Cancel
Save