"tiran" <> wrote in message
news:1a6dcb0f-a7b4-4f7c-9c8c-...
> I wanna use the serial port of sun netra 210 for communication channel
> with an external system. However when I look at the documentation, the
> communation parameters are 9600, 8, n and they are not changeable.
> Does anyone can help me to find a way to change parameters of serial
> port programmatically. Further, If it is possible to change
> parameters, what is maximum baud rate that the port can communicate?
>
> Best regards
references:
Stevens, Advance Prog in UNIX Enviro, Chapt 11, pg.563
man pages on termio(7I), termios(3C)
example code snippets that may help:
#include <fcntl.h>
#include <termios.h>
static char *serial_device_names[] = {
"/dev/ttya",
"/dev/ttyb"};
static char *sunSerialPort = "/dev/ttya"; /* default sun serial port */
#define SUN_SERIAL_PORT_BAUD B9600
static int Fd;
struct termios term;
Fd = open(sunSerialPort, O_RDWR)
term.c_cflag = CS8 | /* 8-bit data */
CREAD | /* enable receiver */
CLOCAL; /* ignore modem status lines */
/* no parity, 1 stop bit */
term.c_oflag &= ~OPOST; /* turn off post processing */
term.c_iflag = IXON | IXOFF | /* Xon/Xoff flow control */
IGNBRK; /* ignore breaks */
/* ISTRIP | */ /* strip input to 7 bits */
/* IGNCR; */ /* ignore received CR */
term.c_lflag = 0; /* everything off in local flag:
disables canonical mode, disables
signal generation, disables echo */
term.c_cc[VMIN] = 1; /* 1 byte at a time, no timer */
term.c_cc[VTIME] = 0; /* block reader indefinitely */
cfsetispeed(&term, SUN_SERIAL_PORT_BAUD);
cfsetospeed(&term, SUN_SERIAL_PORT_BAUD);
tcsetattr(Fd, TCSANOW, &term); /* set attributes now */
printf(" execute '/usr/ucb/stty -a > %s' in a shelltool to display serial
port settings.\n", sunSerialPort);
|