static bool hfa_get_header(struct cgpu_info *hashfast, struct hf_header *h, uint8_t *computed_crc)
{
	int amount, ret, orig_len, len, ofs = 0, reads = 0;
	char buf[512];
	char *header;

	/* Read for up to 200ms till we find the first occurrence of HF_PREAMBLE
	 * though it should be the first byte unless we get woefully out of
	 * sync. */
	orig_len = len = sizeof(*h);
	do {

		if (++reads > 20)
			return false;

		ret = usb_read_timeout(hashfast, buf + ofs, len, &amount, 10, C_HF_GETHEADER);
		if (unlikely(ret && ret != LIBUSB_ERROR_TIMEOUT))
			return false;
		ofs += amount;
		header = memchr(buf, HF_PREAMBLE, ofs);
		if (header)
			len -= ofs - (header - buf);
	} while (len);

	memcpy(h, header, orig_len);
	*computed_crc = hfa_crc8((uint8_t *)h);

	return true;
}
Esempio n. 2
0
static void gc3355_init(struct cgpu_info *gridseed, GRIDSEED_INFO *info)
{
	unsigned char buf[512];
	int amount;

	applog(LOG_NOTICE, "System reseting");
	gc3355_send_cmds(gridseed, str_reset);
	cgsleep_ms(200);
	usb_buffer_clear(gridseed);
	usb_read_timeout(gridseed, buf, sizeof(buf), &amount, 10, C_GETRESULTS);
	gc3355_send_cmds(gridseed, str_init);
	gc3355_send_cmds(gridseed, str_ltc_reset);
	gc3355_set_core_freq(gridseed);
	if (info->voltage)
		gc3355_increase_voltage(gridseed);
}
Esempio n. 3
0
static void gc3355_init(struct cgpu_info *gridseed, GRIDSEED_INFO *info, bool set_nonce)
{
	unsigned char buf[512];
	int amount;

	applog(LOG_NOTICE, "System reseting");
	gc3355_send_cmds(gridseed, str_reset);
	cgsleep_ms(200);
	usb_buffer_clear(gridseed);
	usb_read_timeout(gridseed, buf, sizeof(buf), &amount, 10, C_GETRESULTS);
	gc3355_send_cmds(gridseed, str_init);
	gc3355_send_cmds(gridseed, str_ltc_reset);
	gc3355_set_core_freq(gridseed);
	if (set_nonce)
		gc3355_set_init_nonce(gridseed);
	//gc3355_send_cmds(gridseed, str_baud);
	//gc3355_send_cmds(gridseed, str_enable_btc_cores);
	gc3355_enable_btc_cores(gridseed, info);
	if (info->usefifo == 0)
		gc3355_send_cmds(gridseed, str_nofifo);
	gridseed_request_ltc_task(gridseed, info);
	return;
}