Subject: RE: Using tty code for serial Ports
From: [email-masked] (Sergey Okhapkin)

17 Jul 1997 00:35:11 -0700
Approved: [email-masked]
Distribution: cygnus
Message-ID: <01BC929F.A1722900.cygnus.gnu-win32@sos>
Original-To: "[email-masked]" <[email-masked]>,
        "'Mike Bernson'"
	 <[email-masked]>
Original-Cc: "[email-masked]" <[email-masked]>
Encoding: 42 TEXT
Original-Sender: [email-masked]

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
"[email-masked]" with one line of text: "help".