|
@@ -93,7 +93,7 @@ static void rev(unsigned char *s, size_t l)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static int icarus_open(const char *devpath)
|
|
|
|
|
|
|
+static int icarus_open2(const char *devpath, __maybe_unused bool purge)
|
|
|
{
|
|
{
|
|
|
#ifndef WIN32
|
|
#ifndef WIN32
|
|
|
struct termios my_termios;
|
|
struct termios my_termios;
|
|
@@ -147,10 +147,19 @@ static int icarus_open(const char *devpath)
|
|
|
COMMTIMEOUTS cto = {100, 0, 100, 0, 100};
|
|
COMMTIMEOUTS cto = {100, 0, 100, 0, 100};
|
|
|
SetCommTimeouts(hSerial, &cto);
|
|
SetCommTimeouts(hSerial, &cto);
|
|
|
|
|
|
|
|
|
|
+ if (purge) {
|
|
|
|
|
+ PurgeComm(hSerial, PURGE_RXABORT);
|
|
|
|
|
+ PurgeComm(hSerial, PURGE_TXABORT);
|
|
|
|
|
+ PurgeComm(hSerial, PURGE_RXCLEAR);
|
|
|
|
|
+ PurgeComm(hSerial, PURGE_TXCLEAR);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return _open_osfhandle((LONG)hSerial, 0);
|
|
return _open_osfhandle((LONG)hSerial, 0);
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+#define icarus_open(devpath) icarus_open2(devpath, false)
|
|
|
|
|
+
|
|
|
static int icarus_gets(unsigned char *buf, size_t bufLen, int fd, int thr_id, int read_count)
|
|
static int icarus_gets(unsigned char *buf, size_t bufLen, int fd, int thr_id, int read_count)
|
|
|
{
|
|
{
|
|
|
ssize_t ret = 0;
|
|
ssize_t ret = 0;
|
|
@@ -217,7 +226,7 @@ static bool icarus_detect_one(const char *devpath)
|
|
|
if (total_devices == MAX_DEVICES)
|
|
if (total_devices == MAX_DEVICES)
|
|
|
return false;
|
|
return false;
|
|
|
|
|
|
|
|
- fd = icarus_open(devpath);
|
|
|
|
|
|
|
+ fd = icarus_open2(devpath, true);
|
|
|
if (unlikely(fd == -1)) {
|
|
if (unlikely(fd == -1)) {
|
|
|
applog(LOG_ERR, "Icarus Detect: Failed to open %s", devpath);
|
|
applog(LOG_ERR, "Icarus Detect: Failed to open %s", devpath);
|
|
|
return false;
|
|
return false;
|
|
@@ -287,7 +296,7 @@ static bool icarus_prepare(struct thr_info *thr)
|
|
|
|
|
|
|
|
struct timeval now;
|
|
struct timeval now;
|
|
|
|
|
|
|
|
- int fd = icarus_open(icarus->device_path);
|
|
|
|
|
|
|
+ int fd = icarus_open2(icarus->device_path, true);
|
|
|
if (unlikely(-1 == fd)) {
|
|
if (unlikely(-1 == fd)) {
|
|
|
applog(LOG_ERR, "Failed to open Icarus on %s",
|
|
applog(LOG_ERR, "Failed to open Icarus on %s",
|
|
|
icarus->device_path);
|
|
icarus->device_path);
|