mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-25 14:04:25 +00:00
icarus do the full detect test twice if required
This commit is contained in:
parent
511bbb050c
commit
6e0f93474d
@ -700,6 +700,7 @@ static bool icarus_detect_one(struct libusb_device *dev, struct usb_find_devices
|
|||||||
int baud, work_division, fpga_count;
|
int baud, work_division, fpga_count;
|
||||||
struct cgpu_info *icarus;
|
struct cgpu_info *icarus;
|
||||||
int ret, err, amount, tries;
|
int ret, err, amount, tries;
|
||||||
|
bool ok;
|
||||||
|
|
||||||
icarus = calloc(1, sizeof(struct cgpu_info));
|
icarus = calloc(1, sizeof(struct cgpu_info));
|
||||||
if (unlikely(!icarus))
|
if (unlikely(!icarus))
|
||||||
@ -721,42 +722,42 @@ static bool icarus_detect_one(struct libusb_device *dev, struct usb_find_devices
|
|||||||
|
|
||||||
hex2bin(ob_bin, golden_ob, sizeof(ob_bin));
|
hex2bin(ob_bin, golden_ob, sizeof(ob_bin));
|
||||||
|
|
||||||
tries = 0;
|
tries = 2;
|
||||||
retry:
|
ok = false;
|
||||||
while (++tries) {
|
while (!ok && tries-- > 0) {
|
||||||
icarus_initialise(icarus, baud);
|
icarus_initialise(icarus, baud);
|
||||||
|
|
||||||
err = usb_write(icarus, (char *)ob_bin, sizeof(ob_bin), &amount, C_SENDTESTWORK);
|
err = usb_write(icarus, (char *)ob_bin, sizeof(ob_bin), &amount, C_SENDTESTWORK);
|
||||||
|
|
||||||
if (err == LIBUSB_SUCCESS && amount == sizeof(ob_bin))
|
if (err != LIBUSB_SUCCESS || amount != sizeof(ob_bin))
|
||||||
break;
|
continue;
|
||||||
|
|
||||||
if (tries > 2)
|
|
||||||
goto unshin;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(nonce_bin, 0, sizeof(nonce_bin));
|
memset(nonce_bin, 0, sizeof(nonce_bin));
|
||||||
ret = icarus_get_nonce(icarus, nonce_bin, &tv_start, &tv_finish, NULL, 100);
|
ret = icarus_get_nonce(icarus, nonce_bin, &tv_start, &tv_finish, NULL, 100);
|
||||||
if (ret != ICA_NONCE_OK) {
|
if (ret != ICA_NONCE_OK)
|
||||||
if (tries < 3)
|
continue;
|
||||||
goto retry;
|
|
||||||
goto unshin;
|
|
||||||
}
|
|
||||||
|
|
||||||
nonce_hex = bin2hex(nonce_bin, sizeof(nonce_bin));
|
nonce_hex = bin2hex(nonce_bin, sizeof(nonce_bin));
|
||||||
if (strncmp(nonce_hex, golden_nonce, 8)) {
|
if (strncmp(nonce_hex, golden_nonce, 8) == 0)
|
||||||
|
ok = true;
|
||||||
|
else {
|
||||||
|
if (tries < 0) {
|
||||||
applog(LOG_ERR,
|
applog(LOG_ERR,
|
||||||
"Icarus Detect: "
|
"Icarus Detect: "
|
||||||
"Test failed at %s: get %s, should: %s",
|
"Test failed at %s: get %s, should: %s",
|
||||||
devpath, nonce_hex, golden_nonce);
|
devpath, nonce_hex, golden_nonce);
|
||||||
free(nonce_hex);
|
|
||||||
goto unshin;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
free(nonce_hex);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ok)
|
||||||
|
goto unshin;
|
||||||
|
|
||||||
applog(LOG_DEBUG,
|
applog(LOG_DEBUG,
|
||||||
"Icarus Detect: "
|
"Icarus Detect: "
|
||||||
"Test succeeded at %s: got %s",
|
"Test succeeded at %s: got %s",
|
||||||
devpath, nonce_hex);
|
devpath, golden_nonce);
|
||||||
free(nonce_hex);
|
|
||||||
|
|
||||||
/* We have a real Icarus! */
|
/* We have a real Icarus! */
|
||||||
if (!add_cgpu(icarus))
|
if (!add_cgpu(icarus))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user