1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-30 16:34:23 +00:00

Do a non-blocking read of anything in the avalon buffer after opening the device.

This commit is contained in:
Con Kolivas 2013-05-25 12:11:26 +10:00
parent 6baa23cf62
commit 569a6f65a0
2 changed files with 22 additions and 0 deletions

View File

@ -550,6 +550,25 @@ static void get_options(int this_option_offset, int *baud, int *miner_count,
}
}
/* Non blocking clearing of anything in the buffer */
static void avalon_clear_readbuf(int fd)
{
ssize_t ret;
do {
struct timeval timeout;
char buf[AVALON_FTDI_READSIZE];
fd_set rd;
timeout.tv_sec = timeout.tv_usec = 0;
FD_ZERO(&rd);
FD_SET((SOCKETTYPE)fd, &rd);
ret = select(fd + 1, &rd, NULL, NULL, &timeout);
if (ret > 0)
ret = read(fd, buf, AVALON_FTDI_READSIZE);
} while (ret > 0);
}
static bool avalon_detect_one(const char *devpath)
{
struct avalon_info *info;
@ -571,6 +590,7 @@ static bool avalon_detect_one(const char *devpath)
applog(LOG_ERR, "Avalon Detect: Failed to open %s", devpath);
return false;
}
avalon_clear_readbuf(fd);
/* We have a real Avalon! */
avalon = calloc(1, sizeof(struct cgpu_info));

View File

@ -28,6 +28,8 @@
#define AVALON_DEFAULT_MINER_NUM 0x20
#define AVALON_DEFAULT_ASIC_NUM 0xA
#define AVALON_FTDI_READSIZE 512
struct avalon_task {
uint8_t reset :1;
uint8_t flush_fifo :1;