howto read from serial port?

Rick Stevens ricks at nerd.com
Mon Jun 20 17:12:44 UTC 2011


On 06/20/2011 10:05 AM, Alan Cox wrote:
> On Mon, 20 Jun 2011 08:45:02 -0700
> Mike Wright <mike.wright at mailinator.com> wrote:
> 
>> Hi all,
>>
>> This sure feels like a blast from the past :)
>>
>> I'm trying to figure out how to use com ports to communicate between two 
>> fedora boxes.
>>
>> I've figured out how to set the flow rate (stty /dev/ttyS0 115200) and 
>> to send data:  I have an 80k text file that I "cat textfile > 
>> /dev/ttyS0" and by measuring the TX pin I see the voltage change from 
>> -11.34v to +4.4v for about 10 seconds.  Seems to be working.
>>
>> The problem comes on the other end of the wire.  The receiving machine 
>> is connected by a "null modem" cable.  It seems that standard 
>> redirection should work but I can't figure out the proper shell syntax.
>>
>> Input should listen to /dev/ttyS0 and whenever something is received be 
>> sent to /dev/stdout
> 
> cat /dev/ttyS0
> 

Yup, on the sending side:

	# cat filename >/dev/ttyS0

On the receiving side:

	# cat /dev/ttyS0 >filename

Or, better yet, "yum install minicom" on both machines and run "minicom
-D /dev/ttyS0" on each.  Use "CTRL-A, S" to send a file on one and
"CTRL-A, R" to receive the file on the other, complete with error
checking using X-, Y- or Z-modem protocols.

Man, takes me back to the days of CompuServe, GEnie and dial-up BBSs!


-- 
----------------------------------------------------------------------
- Rick Stevens, Systems Engineer, C2 Hosting          ricks at nerd.com -
- AIM/Skype: therps2        ICQ: 22643734            Yahoo: origrps2 -
-                                                                    -
-           Lottery: A tax on people who are bad at math.            -
----------------------------------------------------------------------


More information about the users mailing list