Serial port line termination

M

Martin Woolley

Hi

I have some code which reads from a serial port. When I use it on one of my
Linux boxes I see 0x0D0A terminating lines read from the device. This is
what I expect to see. But if I run the same code on a different Linux box I
see 0x0A0A as the line terminator.

Here are the options I'm setting in my code:

options.c_cflag |= (CLOCAL | CREAD);
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); // raw mode
options.c_lflag &= ~ECHO;
options.c_oflag &= ~ECHO;
options.c_oflag &= ~OPOST;
options.c_cc[VMIN] = 0;
options.c_cc[VTIME] = 10;

Most of the code that deals with serial port configuration, I got from the
Linux Serial programming HowTo. ie I am pretty new to this and don't
understand it all!

Can anyone tell me how to ensure that I see 0x0D0A terminating all lines
read from the port please? My testing is all wiht /dev/ttyS0 btw.

Thanks
 
J

Joona I Palaste

Martin Woolley said:
I have some code which reads from a serial port. When I use it on one of my
Linux boxes I see 0x0D0A terminating lines read from the device. This is
what I expect to see. But if I run the same code on a different Linux box I
see 0x0A0A as the line terminator.
Here are the options I'm setting in my code:
options.c_cflag |= (CLOCAL | CREAD);
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); // raw mode
options.c_lflag &= ~ECHO;
options.c_oflag &= ~ECHO;
options.c_oflag &= ~OPOST;
options.c_cc[VMIN] = 0;
options.c_cc[VTIME] = 10;
Most of the code that deals with serial port configuration, I got from the
Linux Serial programming HowTo. ie I am pretty new to this and don't
understand it all!
Can anyone tell me how to ensure that I see 0x0D0A terminating all lines
read from the port please? My testing is all wiht /dev/ttyS0 btw.

Not here. ISO standard C knows nothing of serial ports or TTYs. Ask in
comp.unix.programmer or a Linux newsgroup.
 
M

Martin Woolley

Thanks. I'll do that!


Joona I Palaste said:
Martin Woolley said:
I have some code which reads from a serial port. When I use it on one of my
Linux boxes I see 0x0D0A terminating lines read from the device. This is
what I expect to see. But if I run the same code on a different Linux box I
see 0x0A0A as the line terminator.
Here are the options I'm setting in my code:
options.c_cflag |= (CLOCAL | CREAD);
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); // raw mode
options.c_lflag &= ~ECHO;
options.c_oflag &= ~ECHO;
options.c_oflag &= ~OPOST;
options.c_cc[VMIN] = 0;
options.c_cc[VTIME] = 10;
Most of the code that deals with serial port configuration, I got from the
Linux Serial programming HowTo. ie I am pretty new to this and don't
understand it all!
Can anyone tell me how to ensure that I see 0x0D0A terminating all lines
read from the port please? My testing is all wiht /dev/ttyS0 btw.

Not here. ISO standard C knows nothing of serial ports or TTYs. Ask in
comp.unix.programmer or a Linux newsgroup.

--
/-- Joona Palaste ([email protected]) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"I will never display my bum in public again."
- Homer Simpson
 
K

Kenneth Brody

Martin said:
Hi

I have some code which reads from a serial port. When I use it on one of my
Linux boxes I see 0x0D0A terminating lines read from the device. This is
what I expect to see. But if I run the same code on a different Linux box I
see 0x0A0A as the line terminator.
[...]

This has nothing to do with C, but you should check the man pages on
the system call you are using to set the modes, and check the meaning
of the ICRNL flag. If you still need help, check one of the Linux
newsgroups.

--

+---------+----------------------------------+-----------------------------+
| Kenneth | kenbrody at spamcop.net | "The opinions expressed |
| J. | http://www.hvcomputer.com | herein are not necessarily |
| Brody | http://www.fptech.com | those of fP Technologies." |
+---------+----------------------------------+-----------------------------+
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top