Just run a small program to setup the serial device that exits. I had to do
this for a CallerID logger device I attached to an old 486 linux box.
=Rob=
---------- snip ---------------
/*
A simple proggie to setup code to 115200, N, 8, 1, RAW,
no hardware handshaking, etc, etc.
*/
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <termio.h>
#include <stdio.h>
#include <fcntlbits.h>
#include <sys/ioctl.h>
#include <sys/time.h>
const speed_t kBAUDRATE = B115200;
int main(int argc, char **argv )
{
int portfd = -1;
char *serial_name;
int retval = 0;
struct termios tty;
int mcs;
if ( argc == 2 )
{
serial_name = argv[1];
portfd = open(serial_name, O_RDWR|O_SYNC);
if (portfd >= 0)
{
if (!tcgetattr(portfd, &tty))
{
cfsetospeed(&tty, kBAUDRATE);
cfsetispeed(&tty, kBAUDRATE);
tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8;
tty.c_iflag = IGNBRK;
tty.c_lflag = 0;
tty.c_oflag = 0;
tty.c_cflag |= CLOCAL | CREAD;
tty.c_cc[VMIN] = 1;
tty.c_cc[VTIME] = 5;
tty.c_iflag |= IXON | IXOFF;
tty.c_cflag &= ~(PARENB | PARODD);
tcsetattr(portfd, TCSANOW, &tty);
ioctl(portfd, TIOCMGET, &mcs);
mcs |= TIOCM_RTS;
ioctl(portfd, TIOCMSET, &mcs);
}
else
{
retval = errno;
fprintf(stderr,"portsetup: %s on %s\n",
strerror(retval),serial_name);
}
close(portfd);
}
else
{
retval = errno;
fprintf (stderr,"portsetup: Cannot open %s, %s\n",
serial_name, strerror(errno)
);
}
}
else
{
fprintf(stderr, "usage: portsetup serial-device\n");
}
return retval;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Sat Jan 15 2000 - 21:00:18 EST