static int hashratio_get_result(struct thr_info *thr, int fd_detect, struct hashratio_ret *ar) { struct cgpu_info *hashratio; struct hashratio_info *info; int fd; fd = fd_detect; if (thr) { hashratio = thr->cgpu; info = hashratio->device_data; fd = info->fd; } uint8_t result[HRTO_READ_SIZE]; int ret; memset(result, 0, HRTO_READ_SIZE); ret = hashratio_gets(fd, result); if (ret != HRTO_GETS_OK) return ret; // if (opt_debug) { // applog(LOG_DEBUG, "hashratio: Get(ret = %d):", ret); // hexdump((uint8_t *)result, HRTO_READ_SIZE); // } return decode_pkg(thr, ar, result); }
static int hashratio_get_result(struct thr_info *thr, struct hashratio_ret *ar) { struct cgpu_info *hashratio = thr->cgpu; uint8_t result[HRTO_READ_SIZE]; int ret; memset(result, 0, HRTO_READ_SIZE); ret = hashratio_gets(hashratio, result); if (ret != HRTO_GETS_OK) return ret; // if (opt_debug) { // applog(LOG_DEBUG, "hashratio: Get(ret = %d):", ret); // hexdump((uint8_t *)result, HRTO_READ_SIZE); // } return decode_pkg(thr, ar, result); }
static int hashratio_send_pkg(int fd, const struct hashratio_pkg *pkg, struct thr_info __maybe_unused *thr) { int ret; uint8_t buf[HRTO_WRITE_SIZE]; int nr_len = HRTO_WRITE_SIZE; memcpy(buf, pkg, HRTO_WRITE_SIZE); // if (opt_debug) { // applog(LOG_DEBUG, "hashratio: Sent(%d):", nr_len); // hexdump((uint8_t *)buf, nr_len); // } ret = write(fd, buf, nr_len); if (unlikely(ret != nr_len)) { applog(LOG_DEBUG, "hashratio: Send(%d)!", ret); return HRTO_SEND_ERROR; } cgsleep_ms(20); #if 0 ret = hashratio_gets(fd, result); if (ret != HRTO_GETS_OK) { applog(LOG_DEBUG, "hashratio: Get(%d)!", ret); return HRTO_SEND_ERROR; } ret = decode_pkg(thr, &ar, result); if (ret != HRTO_P_ACK) { applog(LOG_DEBUG, "hashratio: PKG(%d)!", ret); hexdump((uint8_t *)result, HRTO_READ_SIZE); return HRTO_SEND_ERROR; } #endif return HRTO_SEND_OK; }