compile avalon driver on win32 and win64
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
diff --git a/driver-avalon.c b/driver-avalon.c
index 7e14a21..0ff9f43 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -17,10 +17,10 @@
#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
-#include <sys/select.h>
#include <dirent.h>
#include <unistd.h>
#ifndef WIN32
+ #include <sys/select.h>
#include <termios.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -28,6 +28,7 @@
#define O_CLOEXEC 0
#endif
#else
+ #include "compat.h"
#include <windows.h>
#include <io.h>
#endif
diff --git a/fpgautils.c b/fpgautils.c
index 61706a5..9330a21 100644
--- a/fpgautils.c
+++ b/fpgautils.c
@@ -592,4 +592,19 @@ int get_serial_cts(int fd)
ioctl(fd, TIOCMGET, &flags);
return (flags & TIOCM_CTS) ? 1 : 0;
}
+#else
+int get_serial_cts(const int fd)
+{
+ if (!fd)
+ return -1;
+ const HANDLE fh = (HANDLE)_get_osfhandle(fd);
+ if (!fh)
+ return -1;
+
+ DWORD flags;
+ if (!GetCommModemStatus(fh, &flags))
+ return -1;
+
+ return (flags & MS_CTS_ON) ? 1 : 0;
+}
#endif // ! WIN32