Setting serial port configuration

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat Setting serial port configuration
# 1  
Old 09-02-2015
Setting serial port configuration

I have 1 serial port (9 Pin) attached with my Linux server.If I give
$dmesg | grep tty , it provides me the following.
ttyS0 and ttyS1.
I have 1 COM port with my server mother board. I have 1 customized application
that requires this COM port to be used.
The parameter to be set for COM port is as follows.
Code:
Baud Rate:- 9600
Data Bit: - 9
Parity: - None
Stop Bit: - 1
Flow Control :- None

How to set these parameters for this COM port(I guess ttyS0 is the required COM port) in Red Hat Linux 5.9?

Last edited by Don Cragun; 09-02-2015 at 04:52 PM.. Reason: Add CODE and ICODE tags.
# 2  
Old 09-02-2015
There's is no such thing as 9 bit RS-232. The road is 8 bits wide, period; you can send 7 bit or 8 bit trucks down it but not 9.

Sometimes you see 8-bit with parity misused to send an extra bit instead of parity. It's a serious pain to communicate with these devices anywhere, the 9th bit ends up coming in as parity error or on a sideband of some sort. You'd use stty to set serial port settings on a Linux system, but there's no setting to make the 8 bit road 9 bits wide, as your computer uses 8-bit bytes, not 9-bit ones.

Your application is going to have to either be modified or read through a filter.

Linux can do slightly better than having to calculate parity for each byte and check if it's error or not to deduce the 9th bit, but only slightly. See mark/space parity for a full explanation.

Last edited by Corona688; 09-02-2015 at 05:52 PM..
# 3  
Old 09-03-2015
It is a typical mistake from My side.Data Bit should be 8 instead of 9.
I need the commands to do so.

---------- Post updated at 06:52 AM ---------- Previous update was at 02:17 AM ----------

To set the following I have used the following command.
Code:
Baud Rate:- 9600 Data Bit: - 8 Parity: - None Stop Bit: - 1 Flow Control :- None
$stty 9600 cs8 -parenb -ixon -cstopb -echo -F /dev/ttyS0

If you see again the parameter by the following command, it shows the attibute as set by the above command.
Code:
$stty -a -F /dev/ttyS0

Do I need to restart the machine after that?

Last edited by vbe; 09-03-2015 at 09:53 AM.. Reason: code tags!!!!
# 4  
Old 09-03-2015
A restart should not be necessary for the current run.

You could also look at the 'raw' extension, (man stty):-

Code:
 stty -F /dev/ttyS0 raw

# 5  
Old 09-03-2015
Quote:
Originally Posted by Anjan Ganguly
It is a typical mistake from My side.Data Bit should be 8 instead of 9.
I need the commands to do so.
Oh, thank goodness -- that's much, much easier.

Quote:
To set the following I have used the following command.
Code:
Baud Rate:- 9600 Data Bit: - 8 Parity: - None Stop Bit: - 1 Flow Control :- None
$stty 9600 cs8 -parenb -ixon -cstopb -echo -F /dev/ttyS0

If you see again the parameter by the following command, it shows the attibute as set by the above command.
Code:
$stty -a -F /dev/ttyS0

Do I need to restart the machine after that?
You do not.

Indeed, if you do, you'll have to set it again. Remember that -- you might want to put it in local.start or in an @reboot cron job.

wisecracker speaks wisely. UNIX serial ports have far more settings than data bits and flow control. See Canonical and noncanonical mode in man termios. What you need depends on the needs of your application (reading lines of text? canonical. reading individual bytes of binary data? raw.)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Serial Port Setting Automatically changes

I am trying to change the setting of serial port baud rate in Red Hat Linux 5.9 by the following command. >> stty 9600 cs8 -parenb -ixon -cstopb -echo -F /dev/ttyS0 The serial port will be used by our custom application in 2 separate servers which are the replica of one another. The port setting... (2 Replies)
Discussion started by: Anjan Ganguly
2 Replies

2. Solaris

Cabling and adapters to communicate to service processor serial port from Windows PC with USB port.

Hello, I have an unloaded T5140 machine and want to access the ILOM for the first time and subsequently the network port after that., and then load Solaris 10 the final January 2011 build. The first part is what confuses me -the cabling. I am coming from a Windows machine (w/appropriate... (5 Replies)
Discussion started by: joboy
5 Replies

3. Solaris

How to enable Serial port on ILOM, when Network Port is enabled in parallel

Hi Everyone, In my environment, I have few T5220. On the iLOM Management Card, I have both Network and Serial port are cabled, I don't have any issues while I try to connect using Network Management port, but when I try to connect the serial port for the same server which is actually connected... (3 Replies)
Discussion started by: bobby320
3 Replies

4. Shell Programming and Scripting

Need help with serial port

Hi, I have a external board connected to my serial port. I need to execute "shutdown -r now" command when system boot up. When system boots up it requires a username ans password. Then I need to run my command. I can use rc script but that is rebooting system before it asks for username and... (0 Replies)
Discussion started by: charlie.arya
0 Replies

5. Solaris

Serial port issue

Hi, I am working with Sun Solaris 9 Sparc,Sun-Blade-100.In my application,I need to monitor the UPS using Serial port. When I am using JRE 1.4 in my application,I am able to monitor it but when I am upgrading the JRE version from 1.4 to JRE1.6. I am not able to monitor the UPS.It is showing the... (1 Reply)
Discussion started by: smartgupta
1 Replies

6. Solaris

Serial port problem

I am working with solaris 9 sparc and I want to connect physical device in serial port but when I am connecting it,It is showing the error window saying-- So can any1 tell me the reason or is there any package I have to add to work with serial port??? (2 Replies)
Discussion started by: smartgupta
2 Replies

7. Programming

Serial port programming

I am developing an application in c with Linux OS, where a radio modem working at baud rate 9600 will be attached to PC on serial port. More than four such units will be communicating at one time, so there may be jamming or data corruption. Each module will be transmitting Data packets less than... (2 Replies)
Discussion started by: raj8109
2 Replies

8. SCO

Serial port configuration

Hi I have just re-installed Compaq ML350 G2 Server with Unix SCO 5.0.5 and informix DBMS . on this server we have 2 serial ports , unfortunately its not working. Can anyone help me to check the serial ports working or not OR guide me to reconfigure it. I have attached a device with... (1 Reply)
Discussion started by: munirh
1 Replies

9. Linux

modem - usb to serial configuration

I have a serial modem connected to a usb port using an adapter cable. The system is a HP DL360. RedHat ES3.0 I am using the device /dev/ttyUSB0 When I issue the command "mgetty ttyUSB0" I get the following output in the log file. How do I get the system to see the modem. 12/02 14:17:55... (2 Replies)
Discussion started by: jshoovie
2 Replies

10. UNIX for Dummies Questions & Answers

serial port configuration

I am having trouble with a device connected through a serial port on my sun workstation ( I am running solaris 7). The seriel device works on an identical workstation running the same o/s version but when I move it to the initial workstation it doesn't work. I am using an rs232 serial cable and... (1 Reply)
Discussion started by: Henrik
1 Replies
Login or Register to Ask a Question