473,734 Members | 2,375 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 5537
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
4057
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
1764
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
10919
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
11056
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
8191
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
2885
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
3791
by: evle | last post by:
haw to read data from an Infrared Infrared Remote Control
3
11623
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
6666
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
8946
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
8776
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
9449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9310
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...
1
9236
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9182
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
3261
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
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.