Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Jan 2000 07:46:00 +0100 (CET)
From:      Andre Albsmeier <andre.albsmeier@mchp.siemens.de>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   ports/16341: Fix for minicom detecting modem status lines
Message-ID:  <200001250646.HAA29228@internal>

next in thread | raw e-mail | index | archive | help

>Number:         16341
>Category:       ports
>Synopsis:       Fix for minicom detecting modem status lines
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jan 24 22:50:01 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     Andre Albsmeier
>Release:        FreeBSD 3.4-STABLE i386
>Organization:
>Environment:

FreeBSD-3.4-STABLE, minicom from the ports.

>Description:

When attempting to dial a number within the dial dialog of minicom
(CTRL-A D), minicom sometimes fails with the error message "You are
already online! Hang up first.". Here is why this might happen:

minicom uses the following code to determine if someone is online:

sysdep1.c, line 172:

----------------------- snip ---------------------------

/* 
 * Get the dcd status
 */
int m_getdcd(fd)
int fd;
{
#ifdef TIOCMODG
  int mcs;
  
  ioctl(fd, TIOCMODG, &mcs);
  return(mcs & TIOCM_CAR ? 1 : 0);
#else
  (void)fd;
  return(0); /* Impossible!! (eg. Coherent) */
#endif
}

----------------------- snap ---------------------------


It tries to determine the carrier detect signal from the modem. To find
out why this fails sometimes, I added some debug stuff to the above
code and the result was that the ioctl fails with error 25 which is
ENOTTY (Inappropriate ioctl for device). Therefore the result in
mcs was undefined and random garbage was returned.


>How-To-Repeat:

Just enter some syslog() debug statements in the above code in order
to log errno.

>Fix:
	
OK, this may be complete bullsh*t but this is what I have done:

I didn't find any reference of TIOCMODG in the kernel sources, especially
not in i386/isa/sio.c. So I replaced all occurences of TIOCMODG with
TIOCMGET and all TIOCMODS with TIOCMODS in sysdep1.c. Then I examined
the result of mcs while playing around with the modem and the values
returned were OK as far as I could tell from the modem LEDs.

The other way would probably be to implement TIOCMODG and TIOCMODS sysctls
but I really don't know much about sysctls :-).

For reference, here is my patch to sysdep1.c:

--- sysdep1.c.orig	Sun Jan 10 16:13:05 1999
+++ sysdep1.c	Tue Jan 25 07:20:42 2000
@@ -64,12 +64,12 @@
 void m_setrts(fd)
 int fd;
 {
-#if defined(TIOCM_RTS) && defined(TIOCMODG)
+#if defined(TIOCM_RTS) && defined(TIOCMGET)
   int mcs;
 
-  ioctl(fd, TIOCMODG, &mcs);
+  ioctl(fd, TIOCMGET, &mcs);
   mcs |= TIOCM_RTS;
-  ioctl(fd, TIOCMODS, &mcs);
+  ioctl(fd, TIOCMSET, &mcs);
 #endif
 #ifdef _COHERENT
   ioctl(fd, TIOCSRTS, 0);
@@ -175,10 +175,10 @@
 int m_getdcd(fd)
 int fd;
 {
-#ifdef TIOCMODG
+#ifdef TIOCMGET
   int mcs;
    
-  ioctl(fd, TIOCMODG, &mcs);
+  ioctl(fd, TIOCMGET, &mcs);
   return(mcs & TIOCM_CAR ? 1 : 0);
 #else
   (void)fd;
@@ -216,8 +216,8 @@
   ioctl(fd, TIOCLGET, &lsw);
 #  endif
 #endif
-#ifdef TIOCMODG
-  ioctl(fd, TIOCMODG, &m_word);
+#ifdef TIOCMGET
+  ioctl(fd, TIOCMGET, &m_word);
 #endif
 }
 
@@ -238,8 +238,8 @@
   ioctl(fd, TIOCLSET, &lsw);
 #  endif
 #endif
-#ifdef TIOCMODS
-  ioctl(fd, TIOCMODS, &m_word);
+#ifdef TIOCMSET
+  ioctl(fd, TIOCMSET, &m_word);
 #endif
 }
 



>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200001250646.HAA29228>