C++: Serial communication - How to read and write characters to or from serial port
2. August 2007Serial communication in C++ is not that easy to achieve. Especially if you want to use an old computer only with DOS installed, it is quite difficult to find some code pieces in the internet. I was looking around for a while on a lot of different coding forums, but mostly the solutions are for windows. Finally I found a nice piece of code on this German website:
http://www.goblack.de/desy/sc12chip/uebung/rs232/serout/desyterm.html
It is a kind of a driver for serial communications if you have an old Borland compiler. For me the tool worked with Borland C++ 3.1 but it should work with later versions, too. With this class you can easily setup the parameters for the com-port and read and write characters from or to the serial port. You can find the download link at the bottom of the page.
I think the code is self-explanatory, but if you have any questions about the use of a function just write a comment here, and I will try to answer it.