Need to disable DTR on serial port

Mike McCormack mike at codeweavers.com
Mon Apr 12 02:46:56 CDT 2004


Hey Rein,

Your patch looks a little more complete than mine :) I was writing an 
improved one, and then saw your patch...  Two comments:

1) it might be better to call COMM_WhackModem() after tcsetattr() so 
previous flow control settings don't interfere with setting the RTS/DTS 
lines.

2) #ifdef guards around TIOCM_DTR and TIOCM_RTS?

Mike

Rein Klazes wrote:

> Geoffrey,
> 
> Please try my patch, submitted two days ago, that is just doing that -
> obeying DTR_CONTROL_DISABLE.
> 
> http://www.winehq.org/hypermail/wine-patches/2004/04/att-0145/01-comm-DTR-RTS-1.diff
> 
> Rein.
-------------- next part --------------
Index: dlls/kernel/comm.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/comm.c,v
retrieving revision 1.77
diff -u -r1.77 comm.c
--- dlls/kernel/comm.c	16 Jan 2004 02:21:01 -0000	1.77
+++ dlls/kernel/comm.c	12 Apr 2004 06:47:01 -0000
@@ -1084,6 +1084,7 @@
 {
      struct termios port;
      int fd, bytesize, stopbits;
+     BOOL r = FALSE;
 
      TRACE("handle %p, ptr %p\n", handle, lpdcb);
      TRACE("bytesize %d baudrate %ld fParity %d Parity %d stopbits %d\n",
@@ -1384,12 +1385,6 @@
 	    TRACE("CRTSCTS\n");
 	  }
 #endif
-
-	if (lpdcb->fDtrControl == DTR_CONTROL_HANDSHAKE)
-	  {
-             WARN("DSR/DTR flow control not supported\n");
-	  }
-
 	if (lpdcb->fInX)
 		port.c_iflag |= IXON;
 	else
@@ -1400,16 +1395,42 @@
 		port.c_iflag &= ~IXOFF;
 
 	if (tcsetattr(fd,TCSANOW,&port)==-1) { /* otherwise it hangs with pending input*/
-	        int save_error=errno;
+                ERR("tcsetattr error '%s'\n", strerror(errno));
                 COMM_SetCommError(handle,CE_IOE);
-                release_comm_fd( handle, fd );
-                ERR("tcsetattr error '%s'\n", strerror(save_error));
-		return FALSE;
 	} else {
                 COMM_SetCommError(handle,0);
-                release_comm_fd( handle, fd );
-		return TRUE;
+		r = TRUE;
 	}
+
+	/* do after we set the com properties, so flow control doesn't interfere */
+#ifdef TIOCM_RTS
+	if (lpdcb->fRtsControl == RTS_CONTROL_DISABLE)
+	  {
+		COMM_WhackModem(fd, ~TIOCM_RTS, 0);
+	  }
+	else if (lpdcb->fRtsControl == RTS_CONTROL_ENABLE)
+	  {
+		COMM_WhackModem(fd, TIOCM_RTS, 0);
+	  }
+#endif
+
+	if (lpdcb->fDtrControl == DTR_CONTROL_HANDSHAKE)
+	  {
+		WARN("DSR/DTR flow control not supported\n");
+	  }
+#ifdef TIOCM_DTR
+	else if (lpdcb->fDtrControl == DTR_CONTROL_DISABLE)
+	  {
+		COMM_WhackModem(fd, ~TIOCM_DTR, 0);
+	  }
+	else if (lpdcb->fDtrControl == DTR_CONTROL_ENABLE)
+	  {
+		COMM_WhackModem(fd, TIOCM_DTR, 0);
+	  }
+#endif
+
+	release_comm_fd( handle, fd );
+	return r;
 }
 
 


More information about the wine-devel mailing list