"The Linux Gazette...making Linux just a little more fun!"


(?) The Answer Guy (!)


By James T. Dennis, tag@lists.linuxgazette.net
LinuxCare, http://www.linuxcare.com/


(?) Setting COM port speeds

From Jason_Magill on Thu, 23 Sep 1999

Answer Guy,

I have an application that I am running that requires me to read the serial port (Com2). The problem is that I need to read it at 9600 7-E-1. How would you go about doing that so when the system is rebooted it will automatically read the serial port at 9600 7-E-1?

I could really use your help.

Thanks, Jason

(!) You should be able to do that with the following command:
		stty 9600 parenb cs7 < /dev/ttyS1
... or something like that.
Note you must redirect INPUT from the serial port to the 'stty' command. This is because the terminal settings are accomplished through an ioctl().
You might also look at the 'setserial' program. It works a bit differently (and is Linux specific) whereas the 'stty' program has been around for UNIX for many years.
Note also that we use ttyS1 for MS-DOS COM2. This is because Linux counts these devices from zero. There is no guarantee that Linux will detect these ports in the same order as MS-DOS, but usually COM2 should be /dev/ttyS1.
The parenb is to set "parity even" (I don't know why the have the "b" there --- for "byte" maybe?) and the cs7 is to set the "character size." There are many other 'stty' settings available. Read the 'man' page for details.


Copyright © 1999, James T. Dennis
Published in The Linux Gazette Issue 48 December 1999
HTML transformation by Heather Stern of Starshine Technical Services, http://www.starshine.org/


[ Answer Guy Current Index ] [ Index of Past Answers ] greetings 1 2 3 5
5 6 7 8 9
10 11 12 13 14 15 16 17 18
19 20 21 22 23 24 25 26 27
28 29 30 31 32 33 34 35 36
37 38 39 40 41 42 43 44 45
46 47 48 49 50 51 52 53 54
55 56 57


[ Table Of Contents ] [ Front Page ] [ Previous Section ] [ Linux Gazette FAQ ] [ Next Section ]