minicom bug and linux kernel 2.6.25.4

R.L. Horn lists at eastcheap.org
Tue Jun 10 03:55:33 UTC 2008


On Mon, 9 Jun 2008, Adam Lackorzynski wrote:

> Looks like I'm seeing the same with my Courier now too but somehow your 
> patch doesn't help (same non-working behaviour with it and without). 
> Need to further investigate this...

Try this one (against the 2.3 sources).  It adds two functions, m_setdtr() 
and, conditionally, m_cleardtr(), that complement m_setrts() (using 
TIOCMOD[GS] instead of TIOCMBI[CS]).  m_setdtr() is called after 
m_setrts() and is also used by m_dtrtoggle(), so RTS and DTR should both 
be positively set.

If that doesn't work, you might check that you have all the serial ioctls 
used by minicom (at least TIOCM_DTR, TIOCM_RTS, TIOCMGET, and TIOCMSET) 
defined.  A quick way to do so, after applying the included patch, is:

   gcc -DHAVE_CONFIG_H -I. -I.. -I../lib -E sysdep1.c | grep m_cleardtr

On my system, (glibc 2.4 built against linux 2.6.18), TIOCM(GET|SET) are 
defined in <asm/iotcls.h> (kernel header included from <bits/ioctl.h> 
included from <sys/ioctl.h>) and TIOCM_(DTR|RTS) are defined in 
<bits/ioctl-types.h> (glibc header included from <sys/ioctl.h>).

In particular, TIOCMGET and TIOCMSET may not be defined depending on the 
state of your userspace kernel headers (i.e. <linux/*> and <asm/*>). 
With the 2.5 and early 2.6 kernels, there was a lot of BS from the linux 
developers about not including kernel headers in userspace programs (they 
maintained that distributors should "sanitize" all the headers) and, for 
some time, the kernel headers were practically unusable.  As a result, a 
lot of screwed-up headers ended up in the wild.



Or, the serial drivers could just be buggered...
-------------- next part --------------
diff -Naur minicom-2.3/src/sysdep1.c minicom-new/src/sysdep1.c
--- minicom-2.3/src/sysdep1.c	2007-10-10 15:18:20.000000000 -0500
+++ minicom-new/src/sysdep1.c	2008-06-09 22:03:39.000000000 -0500
@@ -77,6 +77,42 @@
 #endif
 }
 
+/* Set DTR line. */
+void m_setdtr(int fd)
+{
+#ifdef USE_SOCKET
+    if (portfd_is_socket)
+	return;
+#endif
+
+#if defined(TIOCM_DTR) && defined(TIOCMODG)
+    {
+	int mcs=0;
+
+	ioctl(fd, TIOCMODG, &mcs);
+	mcs |= TIOCM_DTR;
+	ioctl(fd, TIOCMODS, &mcs);
+    }
+#endif
+}
+
+#if defined(TIOCM_DTR) && defined(TIOCMODG) && defined(TIOCMODS)
+/* Clear DTR line. */
+void m_cleardtr(int fd)
+{
+    int mcs = 0;
+
+#ifdef USE_SOCKET
+    if (portfd_is_socket)
+	return;
+#endif
+
+    ioctl(fd, TIOCMODG, &mcs);
+    mcs &= ~TIOCM_DTR;
+    ioctl (fd, TIOCMODS, &mcs);
+}
+#endif
+
 /* Set RTS line. Sometimes dropped. Linux specific? */
 void m_setrts(int fd)
 {
@@ -115,7 +151,12 @@
       sleep(sec);
       ioctl(fd, TIOCSDTR, 0);
     }
-
+#elif defined(TIOCM_DTR) && defined(TIOCMODG) && defined(TIOCMODS)
+    m_cleardtr (fd);
+    if (sec>0) {
+	sleep (sec);
+	m_setdtr (fd);
+    }
 #else /* TIOCSDTR */
 #  if defined (POSIX_TERMIOS) && !defined(_HPUX_SOURCE)
 
@@ -624,6 +665,7 @@
   tcsetattr(fd, TCSANOW, &tty);
 
   m_setrts(fd);
+  m_setdtr(fd);
 #endif /* POSIX_TERMIOS */
 
 #ifndef _DCDFLOW


More information about the minicom-devel mailing list