This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Using tty code for serial Ports


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@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]