Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 05-24-2009, 09:07 AM   #1
LQ Newbie
Registered: Apr 2009
Location: australia
Posts: 12

Rep: Reputation: 0
Question TO write to a serial port

Hi all,

Can anyone tell me the command to write and read data i.ei send & receive data from a computer to a 9 pin serial port in C language????????

Old 05-24-2009, 09:23 AM   #2
Senior Member
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,126
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
In the end its just another file descriptor so most file commands will work on it. If you just want to do command line stuff, I'd use setserial to set up the parameters you want (baud rate, parity, stop bits, ...) and then use whatever to read and write the device file (cat, echo, netcat, socat, ...). Or just use a program like minicom.

If you want to write a C program to do it you'll need to look at tcgetattr and tcsetattr for getting the serial info and setting it up how you want.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem to write to serial port os2 Programming 8 08-23-2016 02:48 AM
is there any shell command to read and write data from parallel and serial port? baosheng Linux - Hardware 2 01-13-2007 08:35 PM
Should be dead simple - read/write serial port from bash ericcarlson Linux - Software 3 10-21-2006 08:35 PM
How do i write to a serial port (modem) in ascii or hex directly? Taliesin.duchaos Linux - Networking 6 04-21-2006 08:31 AM
Serial port Read Write SeanatIL Programming 2 07-14-2004 03:42 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:27 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration