----------------------------------------------------------------------------
OK,
I've received numerous program examples, man page references, etc. that
illustrate how to perform bidirectional serial communications from a generic
UNIX system (mine is an old System V for 8086-based processors name VENIX).
Anyway, I've had no luck. After some delving into the manuals, I think my
system's ports may not be setup correctly. If you feel like looking at my
situation so far and guessing at a suggestion, please read on
----------------------------------------------------------------------------
To verify my connection between the 80486/33 box I'm using and the terminal,
I 1st booted the 80486 with a DOS floppy and a terminal package. Typing on
the 80486 resulted in the characters displaying on the remote terminal.
Conversely, typing on the remote terminal caused characters to appear on the
80486 screen (proving my physical connection is good. Also, note, it is
using a full NULL modem cable).
I then brought back up UNIX on the 80486 and checked out the /etc/inittab
file. It showed:
00:2345:off:/etc/getty /dev/tty00 9600
First of all, if I understand correctly, this should be attempting to put a
login prompt on the remote terminal. Second, the off part indicates it tries
this only once (with respawn instead it would continously retry that).
Anyway, I figured since the getty command would stop running, I could send a
file's contents to the port and it should come out on the other side?
cat temp.txt > /dev/tty00
The result is just a hangup on the UNIX side (until CTRL-C is hit). On the
other side, it does show and indication of ONLINE (from an OFFLINE indicator)
until CTRL-C is hit on the UNIX side. On my remote terminal, this indicates
the control lines have gone high.
An attempt to run a sample piece of code someone sent me also resulted in
nothing (not even a hangup). Note: my remote terminal was set to 1200bps to
match the code. I named the following compiled executable "serial1" and
called it:
serial1 temp.txt /dev/tty00
This code is as follows:
-----------------------------------------------------------------------------
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
/*
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
*/
#include <termio.h>
#include <signal.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <setjmp.h>
#include <sys/lock.h>
#include <errno.h>
#include <sys/times.h>
struct termio ntermio;
struct termio otermio;
SerialConnect(dev, speed, parity, length)
char *dev;
int speed;
int parity;
int length;
{
int fd;
fd = open(dev, O_RDWR, S_IREAD|S_IWRITE);
ioctl(fd, TCGETA, &otermio);
ioctl(fd, TCGETA, &ntermio);
ntermio.c_iflag = 0;
ntermio.c_oflag = 0;
ntermio.c_cflag = HUPCL|CREAD;
switch(speed) {
case 300 :
ntermio.c_cflag |= B300;
break;
case 600 :
ntermio.c_cflag |= B600;
break;
case 1200 :
ntermio.c_cflag |= B1200;
break;
case 2400 :
ntermio.c_cflag |= B2400;
break;
case 4800 :
ntermio.c_cflag |= B4800;
break;
case 9600 :
ntermio.c_cflag |= B9600;
break;
case 19200 :
ntermio.c_cflag |= B19200;
break;
case 38400 :
ntermio.c_cflag |= B38400;
break;
}
switch(parity) {
case 0 :
break;
case 1 :
ntermio.c_cflag |= PARENB;
break;
case 2 :
ntermio.c_cflag |= PARENB;
ntermio.c_cflag |= PARODD;
break;
}
switch(length) {
case 5 :
ntermio.c_cflag |= CS5;
break;
case 6 :
ntermio.c_cflag |= CS6;
break;
case 7 :
ntermio.c_cflag |= CS7;
break;
case 8 :
ntermio.c_cflag |= CS8;
break;
}
ntermio.c_lflag = 0;
ntermio.c_cc[VMIN] = 1;
ntermio.c_cc[VTIME] = 0;
ioctl(fd, TCSETA, &ntermio);
ioctl(fd, TCFLSH, 0);
return fd;
}
SerialDisconnect(fd)
int fd;
{
ioctl(fd, TCSETA, &otermio);
close(fd);
}
main(argc, argv)
int argc;
char **argv;
{
char tmp[128];
int fdmux, fd, len, speed;
if (argc == 3) {
speed = 1200;
if (argc = 4)
speed = atoi(argv[3]);
fdmux = SerialConnect(argv[2], speed, 1, 7);
fd = open(argv[1], O_RDONLY, 0666);
for (;;) {
len = read(fd, tmp, 128);
if (len <= 0)
exit(0);
write(fdmux, tmp, len);
}
} else printf("\n\nUSAGE: serial1 inputfile outputdev\n\n");
}
----------------------------------------------------------------------------
Once again, thanks for all the suggestions so far. Also, thanks for any
further help. I'm a UNIX neophyte surrounded by a cast of UNIX neophytes.
Without some external help, I'm dead in the water. Thanks again!!
Tom_Mo...@Milacron.com