mirror of
https://github.com/GOSTSec/sgminer
synced 2025-02-06 12:04:20 +00:00
avalon_read should not loop but just return whatever it has succeeded in reading.
This commit is contained in:
parent
2c633fdbe4
commit
7ad8af19b9
@ -229,37 +229,33 @@ static bool avalon_decode_nonce(struct thr_info *thr, struct cgpu_info *avalon,
|
|||||||
static int avalon_read(struct cgpu_info *avalon, char *buf, ssize_t len)
|
static int avalon_read(struct cgpu_info *avalon, char *buf, ssize_t len)
|
||||||
{
|
{
|
||||||
ssize_t aread = 0;
|
ssize_t aread = 0;
|
||||||
|
int amount, err, offset, cp;
|
||||||
|
char readbuf[AVALON_FTDI_READSIZE];
|
||||||
|
|
||||||
while (len > 0) {
|
err = usb_read_once_timeout(avalon, readbuf, len, &amount,
|
||||||
int amount, err, offset, cp;
|
AVALON_READ_TIMEOUT, C_AVALON_READ);
|
||||||
char readbuf[AVALON_FTDI_READSIZE];
|
if (err && err != LIBUSB_ERROR_TIMEOUT) {
|
||||||
|
applog(LOG_WARNING, "%s%i: Get avalon read got err %d",
|
||||||
err = usb_read_once_timeout(avalon, readbuf, AVALON_FTDI_READSIZE,
|
avalon->drv->name, avalon->device_id, err);
|
||||||
&amount, AVALON_READ_TIMEOUT,
|
nmsleep(AVALON_READ_TIMEOUT);
|
||||||
C_AVALON_READ);
|
return 0;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (amount < 3)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
offset = 2;
|
|
||||||
do {
|
|
||||||
cp = amount - 2;
|
|
||||||
if (cp > 62)
|
|
||||||
cp = 62;
|
|
||||||
memcpy(&buf[aread], readbuf, cp);
|
|
||||||
aread += cp;
|
|
||||||
amount -= cp + 2;
|
|
||||||
offset += 64;
|
|
||||||
} while (amount > 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return AVA_GETS_OK;
|
if (amount < 3)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
offset = 2;
|
||||||
|
do {
|
||||||
|
cp = amount - 2;
|
||||||
|
if (cp > 62)
|
||||||
|
cp = 62;
|
||||||
|
memcpy(&buf[aread], readbuf, cp);
|
||||||
|
aread += cp;
|
||||||
|
amount -= cp + 2;
|
||||||
|
offset += 64;
|
||||||
|
} while (amount > 2);
|
||||||
|
|
||||||
|
return aread;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait until the ftdi chip returns a CTS saying we can send more data. The
|
/* Wait until the ftdi chip returns a CTS saying we can send more data. The
|
||||||
|
Loading…
x
Reference in New Issue
Block a user