Can't read from ttymxc0

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Can't read from ttymxc0

跳至解决方案
4,848 次查看
laza
Contributor III

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?

标签 (2)
标记 (2)
0 项奖励
回复
1 解答
3,839 次查看
laza
Contributor III

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

在原帖中查看解决方案

0 项奖励
回复
2 回复数
3,839 次查看
laza
Contributor III

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

0 项奖励
回复
3,840 次查看
laza
Contributor III

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

0 项奖励
回复