LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   TO write to a serial port (https://www.linuxquestions.org/questions/linux-newbie-8/to-write-to-a-serial-port-728161/)

payu21 05-24-2009 09:07 AM

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

thanks,
pall

estabroo 05-24-2009 09:23 AM

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.


All times are GMT -5. The time now is 11:49 AM.