[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: serial port loop





On Sat, 1 Mar 2003, Szabo, Tamas wrote:

...
> cat /dev/ttySx and echo Hello > /dev/ttySx
>
> in two terminal window. Txd and RxD was connected to each other. I realised
> that with ttyS0 if I sent once it appears once in the other window. However
> on ttyS1 and ttyS2 seems like an endless loop. The output was:
>
> Hello <newline><nl>
> Hello <nl><nl><nl><nl>
> Hello <nl><nl><nl><nl><nl><nl><nl><nl>
> Hello 16x<nl>
> ...
>
> Is it normal?

Yes, echoing etc are enabled by default.
This is what I do to get a somewhat 'normal' comport:

struct termios term;

tcgetattr(fd, &term);

term.c_lflag &= ~(ICANON | ECHO | ISIG | XCASE);
term.c_cflag |= (CLOCAL | CREAD);

term.c_cflag &= ~CRTSCTS;
term.c_iflag &= ~(INPCK | ISTRIP | IUCLC);
term.c_iflag &= ~(IXON | IXOFF | IXANY);
term.c_cflag &= ~CSIZE;
term.c_cflag |= CS8;
term.c_oflag &= ~OPOST;
term.c_cc[VMIN] = 1;
term.c_cc[VTIME] = 0;

cfsetispeed(&term,B115200);
cfsetospeed(&term,B115200);

tcsetattr(fd,TCSANOW,&term);

Regards,

Pieter