Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 08-20-2003, 11:39 AM   #1
LQ Newbie
Registered: Jun 2003
Posts: 4

Rep: Reputation: 0
Exclamation trouble receiving serial port data

I have a little piece of hardware connected to my serial port which outputs a string when I push a button. However, computer seems to be reading it in as all 0's (in hex). The device is outputting in 9600baud, 1start/1stop bit, no parity, and no handshaking.

I seem to have things set up correctly, and it recieves the data, it is just not the correct data. I have tried recieving with logserial, gtkterm, and miniterm. Logserial and gtkterm both showed the recieved data as being all 0h's.

The cable is wired for 3 wires (ground, trans, rec). It works under hyperterm in windows.

The tx,rx,brk numbers all change as a send, though I don't know what they mean.


cat /proc/tty/driver/serial (ran after powering up device)
serinfo:1.0 driver:5.05c revision:2001-07-08
0: uart:16550A port:3F8 irq:4 baud:9600 tx:443 rx:8352 brk:8340 RTS|DTR|DSR

setserial -gG /dev/ttyS0
/dev/ttyS0 uart 16550A port 0x03f8 irq 4 baud_base 9600 spd_normal auto_irq low_latency

stty -F /dev/ttyS0 -a
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
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
-isig -icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke
Old 08-20-2003, 04:27 PM   #2
LQ Newbie
Registered: Jun 2003
Posts: 4

Original Poster
Rep: Reputation: 0
Lightbulb solution

Ok I got it working.

I was setting the baud_base in setserial to 9600 bacause that's what my hardware device was talking to me at. Then I would read from the serial port with logserial or gtkterm who set the baud rate to 9600.

If one did cat /proc/tty/driver/serial after doing setserial you would
see a baud rate of 800. After starting logserial or gtkterm you would see 9600.

In this case it did not work.

If instead I set the setserial baud_base to 115200 (its boot time
default), cat /proc/tty/driver/serial showes 9600. If I then run
logserial or gtkterm cat /proc/tty/driver/serial still shows 9600
baud. And it works.

The reason:

in the man_page for setserial:

baud_base baud_base
This option sets the base baud rate, which is the clock frequency divided by 16. Normally this value is 115200, which is also the fastest baud rate which the UART can support.

Use the custom divisor to set the speed when the application requests 38.4kb. In this case, the baud rate is the baud_base divided by the divisor. This parameter may be specified by a non-privileged user.

Use 38.4kb when the application requests 38.4kb. This parameter may be specified by a non-privileged user.

divisor divisor
This option sets the custom divison. This divisor will be used then the spd_cust option is selected and the serial port is set to 38.4kb by the application. This parameter may be specified by a non-privileged user.

I'm not using a custom devisor but best I can tell there is a divisor of 12 at work on the baud_base.


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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Not receiving data from serial modem. ejoe Linux - Hardware 18 04-01-2007 12:35 PM
Serial port capture printed data erald Linux - Software 0 04-12-2005 01:12 AM
reading data from a serial port mchitrakar Linux - Networking 3 12-04-2004 01:24 PM
accessing data from serial port PrerakParikh Linux - Hardware 2 08-24-2004 10:17 PM
Log incomming data from a serial port shoekstr Linux - Hardware 6 05-28-2004 10:53 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:13 AM.

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