LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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-29-2009, 06:49 PM   #1
hda7
Member
 
Registered: May 2009
Distribution: Debian wheezy
Posts: 244

Rep: Reputation: 31
serial port configuration


I have a problem with two computers connected via a null modem serial cable.

Both are running Linux 2.6.21.7. I have tried to test the connection sending text directly to /dev/ttyS0 and running `cat /dev/ttyS0' on the other computer. When `echo 'A' >/dev/ttyS0' is run on the first computer, the second shows `A' as expected, but when `cat >/dev/ttyS0' is run and `A' is typed as input, the output consists of several `A's interspersed with a whole lot of newlines. I fooled with the stty configuration, and managed to get different output, but have not been able to produce correct output. Running getty and picocom seems to suffer from this same problem. My current stty config is as follows:
Code:
speed 38400 baud; rows 24; columns 80;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ^J;
eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon ixoff
-iuclc -ixany -imaxbel
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon -iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
-echoctl echoke
Anyone know a configuration that corrects this?

If it helps, I have attached the output associated with `cat >/dev/ttyS0' with `A<nl>' as input.
Attached Files
File Type: txt output.txt (8.0 KB, 2 views)
 
Old 09-29-2009, 07:12 PM   #2
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 114Reputation: 114
Is that a 3-wire null modem cable? Or are you carrying all signals across? I think that cat doesn't send just the character you type in; it sends an entire buffer...but don't hold me to that too closely. Your output looks like a duplexing issue or an overrun of a buffer in your UART. If you are using cts/rts in your configuration without controlling them, that might have something to do with it also.

I haven't done serial work in many years, though at this time I am having to dust those ancient skills off because I may need to do some in the near future...

Why don't you just use minicom instead of cat, anyway?
 
Old 09-29-2009, 08:38 PM   #3
hda7
Member
 
Registered: May 2009
Distribution: Debian wheezy
Posts: 244

Original Poster
Rep: Reputation: 31
The cable carries all signals except ring indicator. Using picocom on both ends suffers the same problem. I tried enabling rts/cts control, but it doesn't seem to help.
 
Old 09-29-2009, 08:58 PM   #4
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 101Reputation: 101
Quote:
Originally Posted by hda7 View Post
I have a problem with two computers connected via a null modem serial cable.

Both are running Linux 2.6.21.7. I have tried to test the connection sending text directly to /dev/ttyS0 and running `cat /dev/ttyS0' on the other computer. When `echo 'A' >/dev/ttyS0' is run on the first computer, the second shows `A' as expected, but when `cat >/dev/ttyS0' is run and `A' is typed as input, the output consists of several `A's interspersed with a whole lot of newlines. I fooled with the stty configuration, and managed to get different output, but have not been able to produce correct output. Running getty and picocom seems to suffer from this same problem. My current stty config is as follows:
Code:
speed 38400 baud; rows 24; columns 80;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ^J;
eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon ixoff
-iuclc -ixany -imaxbel
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon -iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
-echoctl echoke
Anyone know a configuration that corrects this?

If it helps, I have attached the output associated with `cat >/dev/ttyS0' with `A<nl>' as input.
Try this:

# stty -F /dev/ttyS0 raw -echo

on both ends. Then write a small program to avoid using "cat" which may be buffering your data stream.

You would be better off using a terminal program, which will set the required options for you.

If you want to echo locally transmitted characters, leave off the "-echo" option. But this will cause problems once you start two-way communication.
 
Old 10-01-2009, 09:39 AM   #5
hda7
Member
 
Registered: May 2009
Distribution: Debian wheezy
Posts: 244

Original Poster
Rep: Reputation: 31
Thanks, `raw -echo' works. Now I just hace to get init to spawn a getty at boot....
 
  


Reply

Tags
serial port, stty


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
Serial port configuration Xreagan Linux - Distributions 5 11-16-2010 01:51 AM
timedia 4 port serial port i/o card configuration binu_edl Linux - Hardware 0 03-09-2006 09:39 AM
serial port configuration zak_zeem Linux - Networking 4 09-09-2005 07:06 AM
serial port configuration vidyaraj Linux - Hardware 1 02-26-2004 05:01 AM
serial port configuration AndyCanfield Linux - General 1 08-15-2003 04:23 AM


All times are GMT -5. The time now is 04:51 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