LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Best way to program a simple serial routine (http://www.linuxquestions.org/questions/programming-9/best-way-to-program-a-simple-serial-routine-452679/)

nutthick 06-08-2006 02:31 AM

Best way to program a simple serial routine
 
I need to write a piece of software to do the following:

1. Sends a byte through a serial port (triggers an external device to send a reply).
2. Receives a byte from the serial port. This byte is then written to a file.

I've been coding my whole project in bash scripts and perl and don't want to have to learn another language if possible. Can anyone recommend the best way to solve this problem? Any code to setup the serial port would also be appreciated.

Thanks

Theorist 06-13-2006 12:49 PM

Hi nutthick,
I believe you know C. If you don't, then learn it. You can write a C program to read and to write to a serial port.

Two good references that I would suggest will be : -

1.) Serial Programming HOWTO by Gary Frerking available in http://www.tldp.org/HOWTO/Serial-Programming-HOWTO/

2.) Serial Programming Guide for POSIX Operating Systems by Michael R. Sweet which can be downloaded from his site which is http://www.easysw.com/~mike/serial/

Both of them discusses the Input/Output concepts of serial devices well. I am sure you will definitely find them interesting.

With Regards,
Theorist

nutthick 06-20-2006 01:15 AM

Thanks Theorist, C did it without any problems.


All times are GMT -5. The time now is 05:15 PM.