473,698 Members | 2,360 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5533
Martin Woolley <ma****@woolley net.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.progr ammer or a Linux newsgroup.

--
/-- Joona Palaste (pa*****@cc.hel sinki.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.hel sinki.fi> wrote in message
news:c2******** **@oravannahka. helsinki.fi...
Martin Woolley <ma****@woolley net.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.progr ammer or a Linux newsgroup.

--
/-- Joona Palaste (pa*****@cc.hel sinki.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
4052
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 just to understand how Python works (yes, you can call me Python/Linux newbie :) My environment is Fedora Core 4, Python 2.4.1 CSV alone (to read CSV data from the file) and py-serial alone (to read data from the serial port) are working...
1
1758
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 hardware devices simultaneaously. When I run the program on a desktop running Windows 2000 it works fine. When I run it on a Laptop using XP I start having problems. It seems that when the ports are initiated, either one will work but not the
1
10914
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 errors 2) My Nokia 6600 prompted me the message "Accept Connection request from DEMON?" note: DEMON is my computers name. 3) Using my Nokia 6600, I hit the button that refers to the "Yes"
4
11048
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 understand device and serial communication work wihout problems. Now I want to do the same with C# code. As simple as that. I open the serial port with the configuration manufacturer gives me,
15
8185
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 transactions occur? I'm trying to reverse engineer a microcontroller serial routine and I'd like to see any response the chip sends back. Regards, Ken
2
2882
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 LED lamp with 8 seperate light-up sections controlled by a PLD. Each time the PLD clocks, it assigns the value of an input (either high or low) to one of the output pins (0 through 7), and subsequently controls the lamp. I would like my program...
2
3787
by: evle | last post by:
haw to read data from an Infrared Infrared Remote Control
3
11611
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 be working fine when I test it with Hyperterminal . I am using the example program that comes with pyserial, as below. --------------- import serial
6
6661
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 '%' to serial port and make sure it reached the serial port. 2. Once confirmed, send another character.
0
8678
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9030
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5861
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2333
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.