delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/07/17/00:35:11

From: sos AT prospect DOT com DOT ru (Sergey Okhapkin)
Subject: RE: Using tty code for serial Ports
17 Jul 1997 00:35:11 -0700 :
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <01BC929F.A1722900.cygnus.gnu-win32@sos>
Original-To: "sos AT prospect DOT com DOT ru" <sos AT prospect DOT com DOT ru>,
"'Mike Bernson'"
<mike AT mbsun DOT mlb DOT org>
Original-Cc: "gnu-win32 AT cygnus DOT com" <gnu-win32 AT cygnus DOT com>
Encoding: 42 TEXT
Original-Sender: owner-gnu-win32 AT cygnus DOT com

Mike Bernson wrote:
> I would like to use the tty code for serial ports.
>
> What I was hoping for a way the serial port could attach
> to a tty code allowing callbacks for reading, write, ioctl.
>

It's easy to attach serial ports to tty code for the first cygwin 
application runned in the console. First, all three standard handles must 
be redirected to the port on application startup (the tty master attaches 
himself to a device pointed by stderr). Second, modify 
hinfo_vec::init_std_file_from_handle() (hinfo.cc) something like this:

   if (FlushConsoleInputBuffer (handle))
	{
	  bin = 0;
	  if (use_tty)
	    name = "/dev/tty";
	  else
	    name = "/dev/conin";
	}
+   if (GetCommState(handle, &dcb))	// the handle is a serial port
+   {
+	  bin = 1;
+	  if (use_tty)
+	    name = "/dev/tty";
+	  else
+	    name = "com1";
+   }
 }
 MARK();

stdin/stdout/stderr of an application will be conected to tty code, whose 
master side is connected to a serial port. All the childs of the process 
inherits the connection.
getty/login should work fine:-) I've designed tty code with serial handling 
in mind :-)

--
Sergey Okhapkin, http://www.lexa.ru/sos
Moscow, Russia
Looking for a job

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019