Send bytes to serial port

In order to send bytes to the serial port, in Linux use the following commands.

To check the current serial port configuration:

# stty -F /dev/ttyS0 -a

To set the serial port to 9600,8,N,1:

# stty -F /dev/ttyS0 9600 -parenb cs8 -cstopb -crtscts

To send a byte (ex. 0x20 = 20 hexadecimal):

$ printf \x20 > /dev/ttyS0

Advertisements

One thought on “Send bytes to serial port

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s