I'm trying to interface with a serial device (actually the console port of
a routing switch) attached to /dev/tty1p0. If I set up /etc/uucp/Devices to
list it as direct and 9600 bps, cu can connect to it and I can talk to it
just fine.
I now want to automate some of the things I was doing manually through cu. I
created a program which does the following:
..
fd = open("/dev/tty1p0", O_RDWR | O_NDELAY);
/* Undo the O_NDELAY */
fcntl(fd, F_SETFL, 0);
tcgetattr(fd, &ts);
ts.c_iflags = 0;
ts.c_oflags = 0;
ts.c_cflags = CS8|CREAD|CLOCAL|B9600;
ts.c_lflags = IGNBRK|IGNPAR;
ts.c_cc[VMIN] = 0;
ts.c_cc[VTIME] = 10;
tcsetattr(fd, TCSANOW, &ts);
/* Write something, anything */
cmds = "commands\n";
wr = write(fd, cmds, strlen(cmds));
printf("write: %d\n", wr);
/* Read the output */
while((rd = read(fd, buf, buf_sz)) >= 0)
{
/* just print the size */
printf("read: %d\n", rd);
}
..
It's just a little test to see if I can communicate. I have tried playing
with the cflags some. I started up cu on the line and used stty to dump
the settings. No change. On the other hand, if I start cu, then suspend it,
then start my test program, it works correctly. What is it that cu is doing
that I am not? cu apparently undoes whatever it is when it exits -- unless
I kill it with a -9.
It's driving me crazy!!!
Russ
----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web -----
http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
NewsOne.Net prohibits users from posting spam. If this or other posts