Browse Source

Define a minimum polling time based on frequency of mandatory updates of ftdi responses at 40ms.

Con Kolivas 12 years ago
parent
commit
27628cdda9
1 changed files with 6 additions and 0 deletions
  1. 6 0
      usbutils.c

+ 6 - 0
usbutils.c

@@ -64,6 +64,8 @@
 #define ICARUS_TIMEOUT_MS 200
 #define ICARUS_TIMEOUT_MS 200
 #endif
 #endif
 
 
+#define USB_READ_MINPOLL 40
+
 #ifdef USE_BFLSC
 #ifdef USE_BFLSC
 // N.B. transfer size is 512 with USB2.0, but only 64 with USB1.1
 // N.B. transfer size is 512 with USB2.0, but only 64 with USB1.1
 static struct usb_endpoints bas_eps[] = {
 static struct usb_endpoints bas_eps[] = {
@@ -2057,6 +2059,8 @@ int _usb_read(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *pro
 		err = LIBUSB_SUCCESS;
 		err = LIBUSB_SUCCESS;
 		initial_timeout = timeout;
 		initial_timeout = timeout;
 		sleep_time = initial_timeout / 2;
 		sleep_time = initial_timeout / 2;
+		if (sleep_time > USB_READ_MINPOLL)
+			sleep_time = USB_READ_MINPOLL;
 		max = ((double)timeout) / 1000.0;
 		max = ((double)timeout) / 1000.0;
 		cgtime(&read_start);
 		cgtime(&read_start);
 		while (bufleft > 0) {
 		while (bufleft > 0) {
@@ -2134,6 +2138,8 @@ int _usb_read(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *pro
 	err = LIBUSB_SUCCESS;
 	err = LIBUSB_SUCCESS;
 	initial_timeout = timeout;
 	initial_timeout = timeout;
 	sleep_time = initial_timeout / 2;
 	sleep_time = initial_timeout / 2;
+	if (sleep_time > USB_READ_MINPOLL)
+		sleep_time = USB_READ_MINPOLL;
 	max = ((double)timeout) / 1000.0;
 	max = ((double)timeout) / 1000.0;
 	cgtime(&read_start);
 	cgtime(&read_start);
 	while (bufleft > 0) {
 	while (bufleft > 0) {