14 #include <sys/types.h>
19 #include <sys/termios.h>
20 #include <sys/ioctl.h>
30 struct termios orig_termios, cur_termios;
34 fd = open(port_name, O_RDWR | O_NOCTTY | O_NONBLOCK);
37 printf(
"opening modem serial device : fd < 0\n");
41 if (tcgetattr(
fd, &orig_termios)) {
42 printf(
"getting modem serial device attr\n");
45 cur_termios = orig_termios;
48 cur_termios.c_iflag &= ~(IGNBRK | BRKINT | IGNPAR | PARMRK | INPCK | ISTRIP | INLCR | IGNCR
49 | ICRNL | IXON | IXANY | IXOFF | IMAXBEL);
51 cur_termios.c_iflag |= BRKINT;
54 cur_termios.c_oflag &= ~(OPOST | ONLCR | OCRNL | ONOCR | ONLRET);
57 cur_termios.c_cflag &= ~(CSIZE | CSTOPB | CREAD | PARENB | PARODD | HUPCL | CLOCAL);
58 cur_termios.c_cflag |= CREAD | CS8 | CLOCAL;
59 cur_termios.c_cflag &= ~(CRTSCTS);
62 cur_termios.c_lflag &= ~(ISIG | ICANON | IEXTEN | ECHO | FLUSHO | PENDIN);
63 cur_termios.c_lflag |= NOFLSH;
65 if (cfsetspeed(&cur_termios, br)) {
66 printf(
"setting modem serial device speed\n");
70 if (tcsetattr(
fd, TCSADRAIN, &cur_termios)) {
71 printf(
"setting modem serial device attr\n");