|
@@ -285,6 +285,9 @@ static int icarus_write(int fd, const void *buf, size_t bufLen)
|
|
|
{
|
|
{
|
|
|
size_t ret;
|
|
size_t ret;
|
|
|
|
|
|
|
|
|
|
+ if (unlikely(fd == -1))
|
|
|
|
|
+ return 1;
|
|
|
|
|
+
|
|
|
ret = write(fd, buf, bufLen);
|
|
ret = write(fd, buf, bufLen);
|
|
|
if (unlikely(ret != bufLen))
|
|
if (unlikely(ret != bufLen))
|
|
|
return 1;
|
|
return 1;
|
|
@@ -297,7 +300,10 @@ static int icarus_write(int fd, const void *buf, size_t bufLen)
|
|
|
static void do_icarus_close(struct thr_info *thr)
|
|
static void do_icarus_close(struct thr_info *thr)
|
|
|
{
|
|
{
|
|
|
struct cgpu_info *icarus = thr->cgpu;
|
|
struct cgpu_info *icarus = thr->cgpu;
|
|
|
- icarus_close(icarus->device_fd);
|
|
|
|
|
|
|
+ const int fd = icarus->device_fd;
|
|
|
|
|
+ if (fd == -1)
|
|
|
|
|
+ return;
|
|
|
|
|
+ icarus_close(fd);
|
|
|
icarus->device_fd = -1;
|
|
icarus->device_fd = -1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -735,7 +741,7 @@ static bool icarus_reopen(struct cgpu_info *icarus, struct icarus_state *state,
|
|
|
struct ICARUS_INFO *info = icarus->device_data;
|
|
struct ICARUS_INFO *info = icarus->device_data;
|
|
|
|
|
|
|
|
// Reopen the serial port to workaround a USB-host-chipset-specific issue with the Icarus's buggy USB-UART
|
|
// Reopen the serial port to workaround a USB-host-chipset-specific issue with the Icarus's buggy USB-UART
|
|
|
- icarus_close(icarus->device_fd);
|
|
|
|
|
|
|
+ do_icarus_close(icarus->thr[0]);
|
|
|
*fdp = icarus->device_fd = icarus_open(icarus->device_path, info->baud);
|
|
*fdp = icarus->device_fd = icarus_open(icarus->device_path, info->baud);
|
|
|
if (unlikely(-1 == *fdp)) {
|
|
if (unlikely(-1 == *fdp)) {
|
|
|
applog(LOG_ERR, "%"PRIpreprv": Failed to reopen on %s", icarus->proc_repr, icarus->device_path);
|
|
applog(LOG_ERR, "%"PRIpreprv": Failed to reopen on %s", icarus->proc_repr, icarus->device_path);
|
|
@@ -827,6 +833,9 @@ void handle_identify(struct thr_info * const thr, int ret, const bool was_first_
|
|
|
double delapsed;
|
|
double delapsed;
|
|
|
uint32_t nonce;
|
|
uint32_t nonce;
|
|
|
|
|
|
|
|
|
|
+ if (fd == -1)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
// If identify is requested (block erupters):
|
|
// If identify is requested (block erupters):
|
|
|
// 1. Don't start the next job right away (above)
|
|
// 1. Don't start the next job right away (above)
|
|
|
// 2. Wait for the current job to complete 100%
|
|
// 2. Wait for the current job to complete 100%
|
|
@@ -924,6 +933,9 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
|
|
|
fd = icarus->device_fd;
|
|
fd = icarus->device_fd;
|
|
|
info = icarus->device_data;
|
|
info = icarus->device_data;
|
|
|
|
|
|
|
|
|
|
+ if (unlikely(fd == -1) && !icarus_reopen(icarus, state, &fd))
|
|
|
|
|
+ return -1;
|
|
|
|
|
+
|
|
|
if (!state->firstrun) {
|
|
if (!state->firstrun) {
|
|
|
if (state->changework)
|
|
if (state->changework)
|
|
|
{
|
|
{
|