AnsweredAssumed Answered

Can't read from ttymxc0

Question asked by Laza Laza on Jul 16, 2016
Latest reply on Jul 20, 2016 by Laza Laza

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?

Outcomes