Title / Description
Code ... int portd, res; struct termios options, oldtio; char buf[BUFFER_SIZE]; portd = open(PORTDEVICE, O_RDWR | O_NOCTTY | O_NDELAY); fcntl(portd, F_SETFL, 0); if (portd < 0) { perror(PORTDEVICE); exit(-1); } tcgetattr(portd, &oldtio); /* сохраняем текущие настройки порта */ bzero(&options, sizeof(options)); /* очищаем структуру под новые настройки */ options.c_cflag |= (CLOCAL | CREAD); cfsetispeed(&options, BAUDRATE); cfsetospeed(&options, BAUDRATE); options.c_cflag &= ~CSIZE; /* Маскирование битов размера символов */ options.c_cflag |= CS8; /* Установка 8 битов данных */ options.c_cflag |= PARENB; options.c_cflag &= ~PARODD; options.c_cflag &= ~CSTOPB; options.c_iflag |= (INPCK | ISTRIP); options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); options.c_oflag &= ~OPOST; options.c_cc[VMIN] = 10; options.c_cc[VTIME] = 0; tcflush(portd, TCIFLUSH); tcsetattr(portd, TCSANOW, &options); ... tcsetattr(portd, TCSANOW, &oldtio);
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code