Browse Source

Merge commit '50cf259' into cg_merges_20130524b

Conflicts:
	fpgautils.c
Luke Dashjr 12 years ago
parent
commit
ced37d39b5
2 changed files with 16 additions and 1 deletions
  1. 2 1
      driver-avalon.c
  2. 14 0
      fpgautils.c

+ 2 - 1
driver-avalon.c

@@ -17,10 +17,10 @@
 #include <stdio.h>
 #include <stdio.h>
 #include <sys/time.h>
 #include <sys/time.h>
 #include <sys/types.h>
 #include <sys/types.h>
-#include <sys/select.h>
 #include <dirent.h>
 #include <dirent.h>
 #include <unistd.h>
 #include <unistd.h>
 #ifndef WIN32
 #ifndef WIN32
+  #include <sys/select.h>
   #include <termios.h>
   #include <termios.h>
   #include <sys/stat.h>
   #include <sys/stat.h>
   #include <fcntl.h>
   #include <fcntl.h>
@@ -28,6 +28,7 @@
     #define O_CLOEXEC 0
     #define O_CLOEXEC 0
   #endif
   #endif
 #else
 #else
+  #include "compat.h"
   #include <windows.h>
   #include <windows.h>
   #include <io.h>
   #include <io.h>
 #endif
 #endif

+ 14 - 0
fpgautils.c

@@ -931,5 +931,19 @@ int set_serial_rts(int fd, int rts)
 	ioctl(fd, TIOCMSET, &flags);
 	ioctl(fd, TIOCMSET, &flags);
 	return flags & TIOCM_CTS;
 	return flags & TIOCM_CTS;
 }
 }
+#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
 #endif // ! WIN32