I'm trying to write a C++ program that reads a stream of data from a measurement device through an RS-232 serial port and translates it into a readable format. I never coded serial port communication before.
Question: Does anyone have a useful, easy to understand link or a tutorial that might help?
Constraints:
Programming language: C++
OS: Windows (XP) 32 bit
Compilers: MinGW (for prototypin开发者_开发技巧g), Eclipse (final version)
This means:
NO Visual Studio
NO Borland,
NO Code Blocks
NO Blodshed DevC++
The standard Win32 APIs work with handles to communication ports. (In fact the overlapped APIs even worked on Windows 9x/ME!)
If you have access to the boost libraries, there are facilities for doing serial port I/O in boost::asio. The documentation can be a bit cumbersome, but when you get down to brass tacks it's pretty straightforward.
At bbdsoft you can download a good functioning example of a C++ class for using the serial port. Still works great!
精彩评论