#include #include #include #include #include #include #include #define BUF_SIZE 120 main(argc, argv) int argc; char *argv[]; { char buf[BUF_SIZE + 1]; char *dev = "/dev/ttyS0"; int dev_descr; struct termio term_cntl; char *name = argv[0]; if ((dev_descr = open(dev, O_RDWR)) == -1) { sprintf(buf, "%s: couldn't open %s", name, dev); perror(buf); exit(1); } if (ioctl(dev_descr, TCGETA, &term_cntl) == -1) { sprintf(buf, "%s: Couldn't read ioctl for %s", name, dev); perror(buf); exit(1); } term_cntl.c_cflag &= ~CBAUD; term_cntl.c_cflag |= B38400; if (ioctl(dev_descr, TCSETA, &term_cntl) == -1) { sprintf(buf, "%s: Couldn't set ioctl for dev %s", name, dev); perror(buf); exit(1); } exit(0); }