int setup_com(int fd){
struct termios options;
tcgetattr(fd, &options);
/* Set the baud rates to 38400...*/
cfsetispeed(&options, B38400);
cfsetospeed(&options, B38400);
/* Enable the receiver and set local mode...*/
options.c_cflag |= (CLOCAL | CREAD);
/* Set c_cflag options.*/
options.c_cflag |= PARENB;
options.c_cflag &= ~PARODD;
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8;
/* Set c_iflag input options */
options.c_iflag &=~(IXON | IXOFF | IXANY);
options.c_iflag &=~(INLCR | IGNCR | ICRNL);
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
/* Set c_oflag output options */
options.c_oflag &= ~OPOST;
/* Set the timeout options */
options.c_cc[VMIN] = 0;
options.c_cc[VTIME] = 10;
tcsetattr(fd, TCSANOW, &options);
return 1;
}
|