Hi,
we need to use the parit check in our software but we are having trouble to get the information form the termios. We have no parity issues when we are sending data from our software to another PC, where we have an hyper terminal running. We also enabled in our code the PARMRK option but we don't reseive the \377 \000 before the transmitted byte comes. When we are sending a 0xFF to our software we get 2 Bytes from the read function. We inititlize our uart in the following way:
- int uart_init (const char *uartPath)
- {
- struct termios serialConfig
- int fd = open (uartPath, O_RDWR | O_NOCTTY |O_NONBLOCK);
- if (fd < 0) {
- printf("ERROR! %s - opening fd_A \n", strerror(errno));
- return -1;
- }
- tcgetattr(fd,&serialConfig); /* save current port settings */
- cfmakeraw(&serialConfig);
- cfsetispeed(&serialConfig, B9600);
- cfsetospeed(&serialConfig, B9600);
- serialConfig.c_iflag &= ~(IGNBRK | BRKINT | IGNPAR | ICRNL | INLCR | ISTRIP | IGNCR | IUCLC);
- serialConfig.c_iflag |= (IXON | IXOFF | PARMRK | INPCK );
- serialConfig.c_oflag &= ~OPOST;
- serialConfig.c_lflag &= ~(ICANON | IEXTEN | ISIG | ECHO | ECHOE | ECHOK| ECHONL | ECHOCTL);
- serialConfig.c_cflag |= (CLOCAL | CREAD);
- serialConfig.c_cflag &= ~(CSIZE);
- serialConfig.c_cflag |= CS8;
- serialConfig.c_cflag |= PARENB;
- serialConfig.c_cflag |= PARODD;
- serialConfig.c_cflag &= ~(CRTSCTS | CSTOPB);
- serialConfig.c_cc[VMIN] = 1;
- serialConfig.c_cc[VTIME] = 1;
- tcflush(fd, TCIOFLUSH);
- if(tcsetattr(fd, TCSANOW, &serialConfig) != 0) {
- printf("ERROR! %s - set attribute fd_A \n", strerror(errno));
- return -1;
- }
- return fd;
- }
We are pooling the read function in an extra thread. Our read looks like this:
We already did a lot of testing by sending wrong or correct data but we never see the marked parity. My question now is, what are we doing wrong? Did we miss a setup or something?
Kind regards,
Gregor Liebscher