Serial Communication Code for Reading

Hi, does anyone has any simple C++ code to read data from serial port? I'm doing a project to receive a temperature reading for every 5 seconds from the serial port, so it shouldn't be any complicated code needed to be implemented for data queue up function.

I've already searched through google for the code but it is either too complicated, too long to understand or has problem in compilation. So kindly ask for your help here. Thanks!
windows or linux or other OS
I'm using windows vista
This may be of some use.
This is about as simple as it gets
http://msdn.microsoft.com/en-us/library/aa363201%28VS.85%29.aspx

You use ReadFile and Writefile functions once you have the handle to the comport and you have set the baud rate as described in that article
Last edited on
From which library do ReadFile and WriteFile function originate? How to use it? Anyway I plan to incorporate this code into my C++ WinApi, can C mix well with C++?
They are both declared in windows.h (which itself will include the standard api headers) .
The library is kernel32.lib.

The api mix with C++, the api headers have #ifdef __cplusplus conditionals.
Topic archived. No new replies allowed.