[comp.unix.questions] Serial I/O in SCO Unix

TAYBENGH%NUSDISCS.BITNET@cunyvm.cuny.edu (03/21/90)

Hi,
        Can I send and receive data via serial port by calling open(), read()
and write() on tty device? What if the device connected by the serial port is
not a terminal, can I still use the tty device driver as serial-port driver?
If not, how can I poll/read/write serial port just like DOS environment (which
use interrupt)? For example, direct programming the hardware (serial port) in
Unix?
        Any pointers? Thanks in advance..

-Beng Hang Tay (email address: taybengh@nusdiscs.bitnet)
 Department of Information Systems and Computer Science
 National University of Singapore

cpcahil@virtech.uucp (Conor P. Cahill) (03/22/90)

>        Can I send and receive data via serial port by calling open(), read()
>and write() on tty device?

Yes.  It doesn't matter what the device you have attached to the port, you
can treat it as a standard file (that's what UNIX is all about).

>If not, how can I poll/read/write serial port just like DOS environment (which
>use interrupt)? For example, direct programming the hardware (serial port) in
>Unix?

You can't direct program the hardware from unix.  You use ioctl()s to perform
the same kind of functions.  See the termio(7) (not sure about the manual
section numbering under SCO Unix) man page for the ioctl commands and
arguments.


-- 
Conor P. Cahill            (703)430-9247        Virtual Technologies, Inc.,
uunet!virtech!cpcahil                           46030 Manekin Plaza, Suite 160
                                                Sterling, VA 22170 

rbottin@atl.calstate.edu (Richard John Botting) (03/23/90)

>What if the device connected by the serial port is
>not a terminal, can I still use the tty device driver as serial-port driver?
Well - At this moment I am using a SCO Xenix tty port to send
these characters to an AT&T machine thru an X.25 network and lots of
other non-ttys. We have also attached a serial printer to another tty
and told Xenix to use it as a 'lp' - thats in the manual, I think - But
the 'lp' software does handle the ctrl/S-Q synchronization properly
and the buffer overflows.  We have even can attach the UPS alarm output
to a tty if we want to.

As a rule in UNIX, if data flows at all then you can pretend its a tty.
Also there exists software/libraries for programming the tty interface
within UNIX/Xenix - start with stty in the manuals...
Dick Botting
Disclaimer: I'm often wrong.
calstate san bernardino computer science dept. california.