Browse Source

more RTS code

Xiangfu 13 years ago
parent
commit
26fb3aefb9
1 changed files with 19 additions and 3 deletions
  1. 19 3
      fpgautils.c

+ 19 - 3
fpgautils.c

@@ -576,13 +576,29 @@ size_t _select_write(int fd, char *buf, size_t siz, struct timeval *timeout)
 
 int get_serial_cts(int fd)
 {
-	int status;
+	int flags;
 
 	if (!fd)
 		return -1;
 
-	ioctl(fd, TIOCMSET, &status);
-	return status & TIOCM_CTS;
+	ioctl(fd, TIOCMGET, &flags);
+	return flags & TIOCM_CTS;
+}
+
+int set_serial_rts(int fd, int rts)
+{
+	int flags;
+
+	if (!fd)
+		return -1;
+
+	if (rts)
+		flags |= TIOCM_RTS;
+	else
+		flags &= ~TIOCM_RTS;
+
+	ioctl(fd, TIOCMSET, &flags);
+	return flags & TIOCM_CTS;
 }
 
 #endif // ! WIN32