mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-31 00:44:19 +00:00
Do a non-blocking read of anything in the avalon buffer after opening the device.
This commit is contained in:
parent
6baa23cf62
commit
569a6f65a0
@ -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)
|
static bool avalon_detect_one(const char *devpath)
|
||||||
{
|
{
|
||||||
struct avalon_info *info;
|
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);
|
applog(LOG_ERR, "Avalon Detect: Failed to open %s", devpath);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
avalon_clear_readbuf(fd);
|
||||||
|
|
||||||
/* We have a real Avalon! */
|
/* We have a real Avalon! */
|
||||||
avalon = calloc(1, sizeof(struct cgpu_info));
|
avalon = calloc(1, sizeof(struct cgpu_info));
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
#define AVALON_DEFAULT_MINER_NUM 0x20
|
#define AVALON_DEFAULT_MINER_NUM 0x20
|
||||||
#define AVALON_DEFAULT_ASIC_NUM 0xA
|
#define AVALON_DEFAULT_ASIC_NUM 0xA
|
||||||
|
|
||||||
|
#define AVALON_FTDI_READSIZE 512
|
||||||
|
|
||||||
struct avalon_task {
|
struct avalon_task {
|
||||||
uint8_t reset :1;
|
uint8_t reset :1;
|
||||||
uint8_t flush_fifo :1;
|
uint8_t flush_fifo :1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user