Hello everyone...
I have a little problem configuring the UART. I need to open 2 serial connections. The first port I tried (/dev/ttymxc3) works as expected, but when I open /dev/ttymxc2 with the same code, the received data gets stripped of the 7th bit... The port should be a RAW 9600 8Odd1 port with XON/XOFF Flowcontrol...
Code
- #define SERIAL_A "/dev/ttymxc3"
- #define SERIAL_B "/dev/ttymxc2"
- int init_UART_A (void)
- {
- char *portname = SERIAL_A; // Serial1 Portname für Serial 2 ttymxc2
- static int fd;
- struct termios tty;
- fd = open(portname, O_RDWR | O_NOCTTY | O_NDELAY);
- if (fd < 0)
- {
- printf("Error opening %s: %s\n", portname, strerror(errno));
- return -1;
- }
- fcntl(fd, F_SETFL, 0);
- if (tcgetattr(fd, &tty) < 0)
- {
- printf("Error from tcgetattr: %s\n", strerror(errno));
- return -1;
- }
- cfmakeraw(&tty);
- cfsetospeed(&tty, B9600);
- cfsetispeed(&tty, B9600);
- tty.c_cflag |= (CLOCAL | CREAD); /* ignore modem controls */
- tty.c_cflag |= PARENB; /* no parity bit */
- tty.c_cflag |= PARODD; /* Parity ODD */
- tty.c_cflag &= ~CSTOPB; /* only need 1 stop bit */
- tty.c_cflag &= ~CSIZE; /* Mask the character size bits */
- tty.c_cflag |= CS8; /* 8-bit characters */
- tty.c_cflag &= ~CRTSCTS; /* no hardware flowcontrol | */
- tty.c_iflag |= (IXON | IXOFF | IXANY);
- tty.c_iflag |= (INPCK | ISTRIP);
- tty.c_oflag |= OPOST;
- /* fetch bytes as they become available */
- tty.c_cc[VMIN] = 1;
- tty.c_cc[VTIME] = 0;
- tcflush(fd, TCIOFLUSH);
- if (tcsetattr(fd, TCSANOW, &tty) != 0) {
- printf("Error from tcsetattr: %s\n", strerror(errno));
- return -1;
- }
- return fd;
At the moment I don't know what I'm missing... Hope you got any ideas...;)
Best regards,
Jochen Tillner