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.
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?
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.
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.)