Hi,
I am using following code on Nitrogen Linux board to communicate over ttymxc0 with another device(TX,RX, GND only). The problem is that this code is working when built and run on desktop Ubuntu, but not on Nitrogen.
int set_interface_attribs (int fd, int speed, int parity)
{
struct termios tty;
memset (&tty, 0, sizeof tty);
if (tcgetattr (fd, &tty) != 0) {
printf ("error %d from tcgetattr\n", errno);
return -1;
}
cfsetospeed (&tty, speed);
cfsetispeed (&tty, speed);
tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8;
tty.c_iflag &= ~IGNBRK;
tty.c_iflag &= ~(IXON | IXOFF | IXANY);
tty.c_oflag = 0;
// Timeouts are ignored in canonical input mode or when the NDELAY option is set
tty.c_cc[VMIN] = 0; // wait 1st char received
tty.c_cc[VTIME] = 10; // or 1 second
tty.c_cflag |= (CLOCAL | CREAD);
tty.c_cflag &= ~(PARENB | PARODD);
tty.c_cflag |= parity;
tty.c_cflag &= ~(CSTOPB | CRTSCTS);
// raw mode
tty.c_lflag &= ~(ICANON | ECHO | ECHONL | ECHOE | ISIG | IEXTEN);
tty.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
if (tcsetattr (fd, TCSANOW, &tty) != 0) {
printf ("error %d from tcsetattr\n", errno);
return -1;
}
return 0;
}
Port is open with just O_RDWR flag and tcflush is done after setting port parameters.
Program get stuck on read but from /proc/tty/driver/IMX-UART it seems that both transmitted and received bytes increased.
Why doesn't read get these bytes?
Solved! Go to Solution.
Thanks Gary,
but the key problem was getty instance which is started on ttymxc0.
I removed /etc/init/ttymxc0.conf and now it works.
Regards,
Miroslav
Any suggestions on this?
I also tested communication with CuteCom (which I built on the board), but it hangs on read.
And I compared all members of termios structure between Nitrogen's ttymxc0 and my desktop ttyUSB0 and they match.
Regards,
Miroslav
Thanks Gary,
but the key problem was getty instance which is started on ttymxc0.
I removed /etc/init/ttymxc0.conf and now it works.
Regards,
Miroslav