Use direct usb read commands to avoid ftdi data being automatically cut off in avalon reads.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
diff --git a/driver-avalon.c b/driver-avalon.c
index d0acfae..a90dca7 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -242,10 +242,23 @@ static void wait_avalon_ready(struct cgpu_info *avalon)
}
}
+static int avalon_read(struct cgpu_info *avalon, unsigned char *buf, size_t bufsize)
+{
+ struct cg_usb_device *usbdev = avalon->usbdev;
+ int err, amount;
+
+ wait_avalon_ready(avalon);
+ err = libusb_bulk_transfer(usbdev->handle, usbdev->found->eps[DEFAULT_EP_IN].ep,
+ buf, bufsize, &amount, AVALON_READ_TIMEOUT);
+ applog(LOG_DEBUG, "%s%i: Get avalon read got err %d",
+ avalon->drv->name, avalon->device_id, err);
+ return amount;
+}
+
static int avalon_reset(struct cgpu_info *avalon, bool initial)
{
struct avalon_result ar;
- int ret, i, spare, err;
+ int ret, i, spare;
struct avalon_task at;
uint8_t *buf, *tmp;
struct timespec p;
@@ -270,12 +283,7 @@ static int avalon_reset(struct cgpu_info *avalon, bool initial)
return 0;
}
- err = usb_read_once(avalon, (char *)&ar, AVALON_READ_SIZE, &ret,
- C_AVALON_READ);
- applog(LOG_DEBUG, "%s%i: Get avalon read got err %d",
- avalon->drv->name, avalon->device_id, err);
- if (unlikely(err))
- return -1;
+ ret = avalon_read(avalon, (unsigned char *)&ar, AVALON_READ_SIZE);
/* What do these sleeps do?? */
p.tv_sec = 0;
@@ -736,8 +744,8 @@ static void *avalon_get_results(void *userdata)
RenameThread(threadname);
while (42) {
- int amount, err, ofs, cp;
- char buf[rsize];
+ unsigned char buf[rsize];
+ int amount, ofs, cp;
if (offset >= (int)AVALON_READ_SIZE)
avalon_parse_results(avalon, info, thr, readbuf, &offset);
@@ -749,14 +757,7 @@ static void *avalon_get_results(void *userdata)
}
avalon_wait_ready(avalon);
- err = usb_read_once_timeout(avalon, buf, rsize, &amount,
- AVALON_READ_TIMEOUT, C_AVALON_READ);
- if (err && err != LIBUSB_ERROR_TIMEOUT) {
- applog(LOG_WARNING, "%s%i: Get avalon read got err %d",
- avalon->drv->name, avalon->device_id, err);
- nmsleep(AVALON_READ_TIMEOUT);
- continue;
- }
+ amount = avalon_read(avalon, buf, C_AVALON_READ);
if (amount < 3)
continue;