LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
Search this Thread
Old 10-15-2006, 05:26 PM   #1
ma1069
LQ Newbie
 
Registered: Aug 2006
Distribution: ubuntu
Posts: 24

Rep: Reputation: 15
low level serial troubles


Hello,
I'm trying to communicate via serial port to an external device. In Windows, I usually use these settings:

Baud rate: 9600
Data bits: 7
Parity: Even
Stop bit: 1
Flux control: none

Following some examples, I've written some code that surely "sends something" on the line (I've seen it with the oscilloscope) but can't read anything from the line and the external device doesn't seem to understand the commands received.

I've used this configuration code:

Quote:
new_attributes.c_cflag |= CREAD;
new_attributes.c_cflag |= B9600;
new_attributes.c_cflag |= CS7;
new_attributes.c_iflag |= PARENB;
I think that the error is there, but I can't understand what I am missing...

Can someone help me?
 
Old 10-16-2006, 07:33 AM   #2
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Have you taken a look at http://tldp.org/HOWTO/Serial-HOWTO.html?

Last edited by timmeke; 10-16-2006 at 07:36 AM.
 
Old 10-16-2006, 03:15 PM   #3
ma1069
LQ Newbie
 
Registered: Aug 2006
Distribution: ubuntu
Posts: 24

Original Poster
Rep: Reputation: 15
Yes, I've read a similar document to learn how to work...
According to that document, everything should go fine, but isn't so.
The problem is just in the configuration code, I've checked every option (and there are really A LOT, trust me) but without success.
 
Old 10-17-2006, 08:51 AM   #4
ma1069
LQ Newbie
 
Registered: Aug 2006
Distribution: ubuntu
Posts: 24

Original Poster
Rep: Reputation: 15
After weeks of tries, I finally discovered the solution!!
I'll post here just in case that someone else has the same problem...

The right conf is:

Quote:
new_attributes.c_cflag |= PARENB;
new_attributes.c_cflag &= ~PARODD;
new_attributes.c_cflag &= ~CSTOPB;
new_attributes.c_cflag &= ~CSIZE;
new_attributes.c_cflag |= CS7;

tcsetattr(tty_fd, TCSADRAIN, &new_attributes);
The problem was that I was forgotting to disable the wrong parameters!

Thank you, however...
 
  


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
low level format juanb Linux - General 1 02-08-2006 03:16 AM
low-level format DanTaylor Linux - Newbie 7 01-22-2006 03:52 PM
problem with low level i/o programming serial port xatzipol Programming 3 12-17-2005 05:37 AM
Low Level Serial Port Programming novice_din Programming 2 02-08-2005 10:13 PM
low level formatting? hyperpimp Linux - Newbie 16 04-13-2002 12:35 AM


All times are GMT -5. The time now is 08:07 PM.

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