473,385 Members | 1,409 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,385 software developers and data experts.

Help using termios

Hi all

I'm struggeling to get my serial port settings changed using termios.
I can change the baud rate fine, but none of the control flags respond
to my changes. As an example:

#include <stdio.h>
#Iinclude <termios.h>

int main (void) {
struct termios settings;
FILE* pPort;

if (!(pPort = fopen("/dev/ttyUSB0","r+"))) {
printf("Oops0\n");
return 1;
}

if (tcgetattr(fileno(pPort), &settings) != 0) printf("Oops1\n");
cfsetispeed(&settings, B9600);
cfsetospeed(&settings, B9600);
settings.c_iflag |= CSTOPB;
if (tcsetattr(fileno(pPort), TCSANOW, &settings) != 0)
printf("Oops2\n");

fclose(pPort);
}

This will change the current baud rate to the selected 9600, but the
will not set two stop bits as I think it should. What am I doing wrong
here?

Any help would be sincerely appreciated.

Piet
Jun 27 '08 #1
3 4693
goblin wrote:
Hi all

I'm struggeling to get my serial port settings changed using termios.
I can change the baud rate fine, but none of the control flags respond
to my changes.
Termios is not part of the C standard, it's SUS2.

You will find more useful answers in comp.unix.programmer.

--
Pietro Cerutti
Jun 27 '08 #2
Thank you for pointing me to the correct newsgroup. I have reposted
there.
http://groups.google.co.za/group/com...df8e0a4bd205c#
Jun 27 '08 #3
On 22 May 2008 at 13:23, goblin wrote:
I'm struggeling to get my serial port settings changed using termios.
I can change the baud rate fine, but none of the control flags respond
to my changes.
[snip]
settings.c_iflag |= CSTOPB;
You mean settings.c_cflag (control settings, not input).

Jun 27 '08 #4

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

Similar topics

3
by: henry xie | last post by:
Hi, All: I am a newbie in Python. I am trying to use pexpect package in the project. But when I installed the package, it couldn't be used as termios.py was missing. I checked the LIB...
0
by: Richard Taylor | last post by:
User-Agent: OSXnews 2.07 Xref: number1.nntp.dca.giganews.com comp.lang.python:437315 Hi I am trying to use py2app (http://undefined.org/python/) to package a gnome-python application...
2
by: laclac01 | last post by:
I need help, i can't figure out why this code doesnt work. I am using linux. All i want to be able to do is write some text to an LCD attached to my serial port on a linux machine. The LCD is...
5
by: Petr Jakes | last post by:
On my box (Fedora Core4, Python 2.4.1) I am getting following error: >>> import termios, sys >>> fd = sys.stdin.fileno() >>> oldSettings = termios.tcgetattr(fd) Traceback (innermost last): File...
4
by: Sreekanth | last post by:
Hi all, I have implemented a timing out version of fgets function call. I am pasting the entire code below. I have following doubts: 1. The code which I have written does it follow standard C...
6
by: hem | last post by:
Hi, I have the following small program which read password from user after echoing off. But the problem is, it is freezing for some time (not sure about the duration) before going to the next...
1
by: jmalone | last post by:
I have a python script that I need to freeze on AIX 5.1 (customer has AIX and does not want to install Python). The python script is pretty simple (the only things it imports are sys and socket)....
0
by: Laszlo Nagy | last post by:
Hi All, I have a python program that downloads database backups from a remote server, and tries to replace the local database with the downloaded backup. The database is a PostgreSQL server and my...
14
by: pgfdbug | last post by:
First I am learning this as I go so please forgive my ignorance, all is self taught. I was given this as program to run an LED signboard for my fire station. The program is supposed to transmit the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.