LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 09-19-2006, 11:44 AM   #1
DavidHB
Member
 
Registered: Feb 2006
Location: Chile
Distribution: Slackware 10.2
Posts: 53

Rep: Reputation: 15
managing termios for ser ports


I am trying to follow an example for simple serial port IO. ttyS0 for example.

I have a problem with the termios values particularly c_cflag and or cfsetispeed / cfsetospeed.

For the funtion cfsetispeed for example, it refers to a value like B38400, which they say is defined as 38400, or, #define B38400 38400. But using the other method to set termios.c_cflag it's supposed to be an OR of varios controls, like ( CS8 | B38400 | CLOCAL | CREAD ) for instance. Here obvious B38400 = 38400 is obviously not compatible to this flag setting. The bits would conflict with others.

In my termbits.h it says the following
#define B38400 00000017 !!!!
NOTE it does NOT say
#define B38400 0x00000017

If I use cfsetispeed (with B38400) c_cflag is not changed ( using 38400 or 0x00000017 or B_38400 ).

I cannot make the serial port work, even though the "open" returns a good fd.

What is going on??

DavidHB
 
Old 09-20-2006, 04:30 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
B38400 not defined as 38400. It's 'something' that reflects the baudrate 38400. The value is 15 which matches your termbits.h (00000017 is an octal value, so 1*8 + 7 = 15). You can print the value with a simple printf.

I've posted an init routine that I usually use in this thread
 
Old 09-21-2006, 07:37 AM   #3
DavidHB
Member
 
Registered: Feb 2006
Location: Chile
Distribution: Slackware 10.2
Posts: 53

Original Poster
Rep: Reputation: 15
Wim,

Thanks for the clarification. It hadn't occured to me that it was octal, and some other references that I had seen indicated that B38400 defined directly to 38400(??) so I was left with a confusion. Hex ( or Octal ) made more sense to me. I'm not at my office today, but when I get back I'll take another look.

Thanks for the in depth response.

Dave
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SER H.323 Supprt sailu_mvn Linux - Software 1 01-21-2011 03:48 PM
Problem with Ser Service Status: ser dead but subsys locked Reu Linux - Software 2 11-03-2007 12:00 PM
problem with serial port in loopback mode .. (termios) mta Programming 1 06-06-2006 11:56 AM
ser vs asterisk sailu_mvn Linux - Software 3 04-01-2006 04:21 PM
Figuring out a 'c_oflag'(man termios) that will help in stdout supression. Tarts Programming 13 08-11-2003 09:04 AM


All times are GMT -5. The time now is 12:05 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration