473,408 Members | 1,601 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Serial port line termination

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

Nov 14 '05 #1
3 5512
Martin Woolley <ma****@woolleynet.com> scribbled the following:
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.


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

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"I will never display my bum in public again."
- Homer Simpson
Nov 14 '05 #2
Thanks. I'll do that!
"Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message
news:c2**********@oravannahka.helsinki.fi...
Martin Woolley <ma****@woolleynet.com> scribbled the following:
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.


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

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"I will never display my bum in public again."
- Homer Simpson

Nov 14 '05 #3
Martin Woolley wrote:

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." |
+---------+----------------------------------+-----------------------------+
Nov 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: McBooCzech | last post by:
Hi I am just trying to analyze (parse) data from the serial port (I have connected GPS receiver to the ttyS0, so I can read ASCII characters in the CSV form on the serial port 1). I am doing this...
1
by: David | last post by:
I have written an application in VB.NET 2003 that uses the SAX serial component for RS232 communications with hardware. The program sets up 2 serial ports so that it can talk to 2 different...
1
by: henrycortezwu | last post by:
Hi All, I'm trying to connect to a virtual port (COM19, OUTGOING, "Bluetooth Serial Port") using VS2005 System.IO.Ports. When I ran the ff code below here's what happens. 1) VS2005 Compiles w/o...
4
by: Lonifasiko | last post by:
Hi, I've been able to communicate using HyperTerminal with my device via serial port COM1. I just send a command and device switches on. I just need that to start playing with it. This way, I...
15
by: xkenneth | last post by:
Hi, I'm writing a couple python applications that use the serial port (RS-232) quite extensively. Is there any way I can monitor all activity on the serial port and have it printed as the...
2
by: zdicklin | last post by:
I am working on a very simple hardware project and would like to develop serial port controls, but I'm having a little bit of trouble starting out. The project is the following: I have built an...
2
by: evle | last post by:
haw to read data from an Infrared Infrared Remote Control
3
by: naveen.sabapathy | last post by:
Hi, I am trying to use virtual serial ports to develop/test my serial communication program. Running in to trouble... I am using com0com to create the virtual ports. The virtual ports seem to...
6
by: terry | last post by:
Hi, I am trying to send a character to '/dev/ttyS0' and expect the same character and upon receipt I want to send another character. I tired with Pyserial but in vain. Test Set up: 1. Send...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.