* Raw Serial Port
@ 1996-10-22 4:00 Richard W. Franzen
1996-10-28 5:00 ` Simon Elliott
0 siblings, 1 reply; 2+ messages in thread
From: Richard W. Franzen @ 1996-10-22 4:00 UTC (permalink / raw)
Cc: richf
Under the old SunOS 4.x.x, one could obtain a raw serial device
(no os interceptions of data between device and application) using
ioctl() calls and the sgttyb structure:
status = ioctl(fd, TIOCGETP, &mygtty);
..
mygtty.sg_flags |= RAW;
mygtty.sg_flags &= ~(ECHO);
..
status = ioctl(fd, TIOCSETP, &mygtty);
Now there is the new & better & standard & Posix & @$%@#^% termios
infrastructure. None of the documentation I can find states, "here is
how you have the goshdarn os leave serial data alone", so we are trying
to translate the above using then information in the termios man
page. So far, we have:
status = tcgetattr(fd, &myAttr);
..
myAttr.c_iflag &= (IXOFF | IXANY);
myAttr.c_oflag &= ~(OPOST);
myAttr.c_cflag &= ~(PARENB | PARODD | CSTOPB);
myAttr.c_cflag |= (CS8 | CLOCAL);
myAttr.c_lflag &= ~(XCASE | ICANON | ISIG);
myAttr.c_lflag &= ~(ECHO);
..
myAttr.c_cc[VMIN] = 1;
myAttr.c_cc(VTIME] = 0;
..
status = tcsetattr(fd, TCSANOW, &myAttr);
which, unfortunately, does not work as we would like. Certain
characters from the device still get eaten by the os. The serial
protocol we use was designed a long time ago, assuming pure binary
data could be passed between Unix and the device.
It is extremely likely that we are not setting\clearing something
which we should be. Unfortunately, it is not clear what. Six months
ago we solved the problem by giving up on the new way and using the
Solaris -> SunOS compatibility stuff (including <sys/ttold.h> and
<sys/ttcompat.h>), which allowed the use of the sgttyb stuff. This
works fine.
Now we are porting to Digital Unix 4.0, which obviously does not
bother with SunOS backwards compatibility. (They do document
BSD compatibity methods for code using sgttyb, but it is not
the same as Sun implemented it.) The "right" way to go should be to
use the new Posix termios method for controlling the serial port.
So, if anyone knows the magic Posix incantation to have Unix not do
any filtering of serial data--period--please share the spell.
Thanks, Rich
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Rich Franzen richf@dba-sys.com (work)
Staff Scientist rfranzen@digital.net (home)
DBA Systems, Inc. 407/727-0660 x2294 (voice)
1200 S. Woody Burke Rd. 407/727-7019 (fax)
Melbourne, FL 32901 {`DBA' != "doing business as"}
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: Raw Serial Port
1996-10-22 4:00 Raw Serial Port Richard W. Franzen
@ 1996-10-28 5:00 ` Simon Elliott
0 siblings, 0 replies; 2+ messages in thread
From: Simon Elliott @ 1996-10-28 5:00 UTC (permalink / raw)
In article <326CDFC7.41C6@dba-sys.com>, richf@dba-sys.com says...
[SNIP]
> Now we are porting to Digital Unix 4.0, which obviously does not
>bother with SunOS backwards compatibility. (They do document
>BSD compatibity methods for code using sgttyb, but it is not
>the same as Sun implemented it.) The "right" way to go should be to
>use the new Posix termios method for controlling the serial port.
>So, if anyone knows the magic Posix incantation to have Unix not do
>any filtering of serial data--period--please share the spell.
We're having this problem on Solaris 2.5. The standard POSIX way to get a raw
serial port is as follows:
struct termios MyTermios;
int MyFile;
if (tcgetattr (MyFile, &MyTermios) == -1)
/* error */
MyTermios.c_cc[VMIN] = 1;
MyTermios.c_cc[VTIME] = 0;
MyTermios.c_lflag &= ~(ECHO|ICANON|ISIG|ECHOE|ECHOK|ECHONL);
MyTermios.c_oflag &= ~(OPOST);
if (tcsetattr (MyFile, TCSANOW, &MyTermios) == -1)
/* error */
You also probably want to get rid of xon/xoff processing and a few other
undesirable things:
MyTermios.c_iflag &= ~(BRKINT|ICRNL|INLCR|ISTRIP|IXOFF|IXON|PARMRK);
As far as I'm aware there is no standard POSIX way of disabling hardware flow
control, should you want to do this.
I would be interested in hearing how this works out on your system.
Regards
Simon Elliott Geco-Prakla
Senior Software Engineer Schlumberger House
Land Acquisition Technical Support Buckingham Gate
voice : +44 1293 55 6649 GATWICK AIRPORT
fax : +44 1293 55 6640 RH6 0NZ
email : ellios@gatwick.geco-prakla.slb.com United Kingdom
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1996-10-28 5:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-10-22 4:00 Raw Serial Port Richard W. Franzen
1996-10-28 5:00 ` Simon Elliott
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox