Mark Aubin (aubin++at++mustang.engr.sgi.com)
Wed, 29 Sep 1999 12:19:23 -0700 (PDT)
Hi Murray,
Yes, it is all clear now.
You cannot use the serial devices reliably in the manner stated.
You must use the ioctl command to set the state of the
serial port. If you don't, the port will be in an unknown
state. Could be wrong baud rate, wrong data bits, wrong
flow control, etc.
I put together a program that will let you check the state
of a serial port. This will reveal why some ports work and
some don't.
http://reality.sgi.com/aubin/checkport.c
Here's an example of how to set the port for a B&G flybox:
int fd;
struct termio tio;
if ((fd = open("/dev/ttyd2", O_RDWR|O_NDELAY)) == -1) {
fprintf(stderr, "Failed to open port.\n");
exit(-1);
}
tio.c_iflag = IGNBRK|IXON|IXOFF;
tio.c_oflag = 0;
tio.c_cflag = CS8|CREAD|CLOCAL;
tio.c_lflag = ICANON;
tio.c_ospeed = B19200;
if ((ioctl(fd, TCSETAF, &tio)) < 0) {
fprintf(stderr, "Failed to initialize port.\n");
exit(-1);
}
--Mark Aubin
aubin++at++sgi.com
This archive was generated by hypermail 2.0b2 on Wed Sep 29 1999 - 12:19:31 PDT