|
|
@ -2035,7 +2035,7 @@ int _usb_read(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *pro |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
struct timeval read_start, tv_finish; |
|
|
|
struct timeval read_start, tv_finish; |
|
|
|
unsigned int initial_timeout; |
|
|
|
unsigned int initial_timeout; |
|
|
|
double done; |
|
|
|
double max, done; |
|
|
|
int bufleft, err, got, tot; |
|
|
|
int bufleft, err, got, tot; |
|
|
|
__maybe_unused bool first = true; |
|
|
|
__maybe_unused bool first = true; |
|
|
|
unsigned char *search; |
|
|
|
unsigned char *search; |
|
|
@ -2069,6 +2069,7 @@ int _usb_read(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *pro |
|
|
|
bufleft = bufsiz; |
|
|
|
bufleft = bufsiz; |
|
|
|
err = LIBUSB_SUCCESS; |
|
|
|
err = LIBUSB_SUCCESS; |
|
|
|
initial_timeout = timeout; |
|
|
|
initial_timeout = timeout; |
|
|
|
|
|
|
|
max = ((double)timeout) / 1000.0; |
|
|
|
cgtime(&read_start); |
|
|
|
cgtime(&read_start); |
|
|
|
while (bufleft > 0) { |
|
|
|
while (bufleft > 0) { |
|
|
|
if (ftdi) |
|
|
|
if (ftdi) |
|
|
@ -2112,8 +2113,10 @@ int _usb_read(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *pro |
|
|
|
|
|
|
|
|
|
|
|
done = tdiff(&tv_finish, &read_start); |
|
|
|
done = tdiff(&tv_finish, &read_start); |
|
|
|
// N.B. this is: return LIBUSB_SUCCESS with whatever size has already been read
|
|
|
|
// N.B. this is: return LIBUSB_SUCCESS with whatever size has already been read
|
|
|
|
|
|
|
|
if (unlikely(done >= max)) |
|
|
|
|
|
|
|
break; |
|
|
|
timeout = initial_timeout - (done * 1000); |
|
|
|
timeout = initial_timeout - (done * 1000); |
|
|
|
if (timeout <= 0) |
|
|
|
if (!timeout) |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2132,6 +2135,7 @@ int _usb_read(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *pro |
|
|
|
endlen = strlen(end); |
|
|
|
endlen = strlen(end); |
|
|
|
err = LIBUSB_SUCCESS; |
|
|
|
err = LIBUSB_SUCCESS; |
|
|
|
initial_timeout = timeout; |
|
|
|
initial_timeout = timeout; |
|
|
|
|
|
|
|
max = ((double)timeout) / 1000.0; |
|
|
|
cgtime(&read_start); |
|
|
|
cgtime(&read_start); |
|
|
|
while (bufleft > 0) { |
|
|
|
while (bufleft > 0) { |
|
|
|
if (ftdi) |
|
|
|
if (ftdi) |
|
|
@ -2193,8 +2197,10 @@ int _usb_read(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *pro |
|
|
|
|
|
|
|
|
|
|
|
done = tdiff(&tv_finish, &read_start); |
|
|
|
done = tdiff(&tv_finish, &read_start); |
|
|
|
// N.B. this is: return LIBUSB_SUCCESS with whatever size has already been read
|
|
|
|
// N.B. this is: return LIBUSB_SUCCESS with whatever size has already been read
|
|
|
|
|
|
|
|
if (unlikely(done >= max)) |
|
|
|
|
|
|
|
break; |
|
|
|
timeout = initial_timeout - (done * 1000); |
|
|
|
timeout = initial_timeout - (done * 1000); |
|
|
|
if (timeout <= 0) |
|
|
|
if (!timeout) |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2215,7 +2221,7 @@ int _usb_write(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *pr |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
struct timeval read_start, tv_finish; |
|
|
|
struct timeval read_start, tv_finish; |
|
|
|
unsigned int initial_timeout; |
|
|
|
unsigned int initial_timeout; |
|
|
|
double done; |
|
|
|
double max, done; |
|
|
|
__maybe_unused bool first = true; |
|
|
|
__maybe_unused bool first = true; |
|
|
|
int err, sent, tot; |
|
|
|
int err, sent, tot; |
|
|
|
|
|
|
|
|
|
|
@ -2235,6 +2241,7 @@ int _usb_write(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *pr |
|
|
|
tot = 0; |
|
|
|
tot = 0; |
|
|
|
err = LIBUSB_SUCCESS; |
|
|
|
err = LIBUSB_SUCCESS; |
|
|
|
initial_timeout = timeout; |
|
|
|
initial_timeout = timeout; |
|
|
|
|
|
|
|
max = ((double)timeout) / 1000.0; |
|
|
|
cgtime(&read_start); |
|
|
|
cgtime(&read_start); |
|
|
|
while (bufsiz > 0) { |
|
|
|
while (bufsiz > 0) { |
|
|
|
sent = 0; |
|
|
|
sent = 0; |
|
|
@ -2263,8 +2270,10 @@ int _usb_write(struct cgpu_info *cgpu, int ep, char *buf, size_t bufsiz, int *pr |
|
|
|
|
|
|
|
|
|
|
|
done = tdiff(&tv_finish, &read_start); |
|
|
|
done = tdiff(&tv_finish, &read_start); |
|
|
|
// N.B. this is: return LIBUSB_SUCCESS with whatever size was written
|
|
|
|
// N.B. this is: return LIBUSB_SUCCESS with whatever size was written
|
|
|
|
|
|
|
|
if (unlikely(done >= max)) |
|
|
|
|
|
|
|
break; |
|
|
|
timeout = initial_timeout - (done * 1000); |
|
|
|
timeout = initial_timeout - (done * 1000); |
|
|
|
if (timeout <= 0) |
|
|
|
if (!timeout) |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|