开发者

Serial port communication tutorial [closed]

开发者 https://www.devze.com 2023-02-28 02:43 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely solicit debate, a
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

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!

0

精彩评论

暂无评论...
验证码 换一张
取 消