Ejemplo n.º 1
0
static int avalon2_get_result(struct thr_info *thr, int fd_detect, struct avalon2_ret *ar)
{
	struct cgpu_info *avalon2;
	struct avalon2_info *info;
	int fd;

	fd = fd_detect;
	if (thr) {
		avalon2 = thr->cgpu;
		info = avalon2->device_data;
		fd = info->fd;
	}

	uint8_t result[AVA2_READ_SIZE];
	int ret;

	memset(result, 0, AVA2_READ_SIZE);

	ret = avalon2_gets(fd, result);
	if (ret != AVA2_GETS_OK)
		return ret;

	if (opt_debug) {
		applog(LOG_DEBUG, "Avalon2: Get(ret = %d):", ret);
		hexdump((uint8_t *)result, AVA2_READ_SIZE);
	}

	return decode_pkg(thr, ar, result);
}
Ejemplo n.º 2
0
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);
}
Ejemplo n.º 3
0
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);
}
Ejemplo n.º 4
0
static int avalon2_send_pkg(int fd, const struct avalon2_pkg *pkg,
			    struct thr_info __maybe_unused *thr)
{
	int ret;
	uint8_t buf[AVA2_WRITE_SIZE];
	size_t nr_len = AVA2_WRITE_SIZE;

	memcpy(buf, pkg, AVA2_WRITE_SIZE);
	if (opt_debug) {
		applog(LOG_DEBUG, "Avalon2: Sent(%ld):", nr_len);
		hexdump((uint8_t *)buf, nr_len);
	}

	ret = write(fd, buf, nr_len);
	if (unlikely(ret != nr_len)) {
		applog(LOG_DEBUG, "Avalon2: Send(%d)!", ret);
		return AVA2_SEND_ERROR;
	}

	cgsleep_ms(20);
#if 0
	ret = avalon2_gets(fd, result);
	if (ret != AVA2_GETS_OK) {
		applog(LOG_DEBUG, "Avalon2: Get(%d)!", ret);
		return AVA2_SEND_ERROR;
	}

	ret = decode_pkg(thr, &ar, result);
	if (ret != AVA2_P_ACK) {
		applog(LOG_DEBUG, "Avalon2: PKG(%d)!", ret);
		hexdump((uint8_t *)result, AVA2_READ_SIZE);
		return AVA2_SEND_ERROR;
	}
#endif

	return AVA2_SEND_OK;
}
Ejemplo n.º 5
0
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;
}