Can't read from ttymxc0

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Can't read from ttymxc0

ソリューションへジャンプ
3,606件の閲覧回数
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 解決策
2,597件の閲覧回数
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 返答(返信)
2,597件の閲覧回数
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 件の賞賛
返信
2,598件の閲覧回数
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 件の賞賛
返信