项目作者: jensen-loouq

项目描述 :
A modern C++ wrapper class for the Win32 API serial communications.
高级语言: C++
项目地址: git://github.com/jensen-loouq/Windows-Device-Serial-Cpp.git
创建时间: 2019-09-14T18:17:22Z
项目社区:https://github.com/jensen-loouq/Windows-Device-Serial-Cpp

开源协议:GNU General Public License v3.0

下载


Windows-Desktop-Serial

serial logo
A modern C++ wrapper class for the Win32 API serial communications. The Win32 API for serial communication is documented around 1995, and slightly difficult to use (especially for those not familiar with C).
This wrapper class seeks to make the consumption of the Win32 Serial API easier to use, by porting it to C++11 language standards and with the support of the STL. This wrapper class pursues a design to force
the creation of serial devices during runtime.

Getting Started

Dependencies

Building

  • MSVC
  • Clang: Make sure to have a C++11 supported version.
  • GCC: If you have MinGW, you can build using g++ with the provided makefile.

Examples

Basic Send (reactive - event handles receive)

  1. #include <iostream>
  2. #include <Win32.Devices.SerialDevice.h>
  3. using namespace Win32::Devices;
  4. void HandleRxData(std::string);
  5. int main()
  6. {
  7. SerialDevice at_port = { SerialDevice::FromPortNumber(10) };
  8. at_port.UsingEvents(true);
  9. at_port.ReceivedData += HandleRxData;
  10. at_port.BaudRate(CBR_115200);
  11. // turn off echo
  12. at_port.Write("ATE0\r");
  13. while (true)
  14. ;
  15. }
  16. void HandleRxData(std::string in)
  17. {
  18. std::cout << in << std::endl;
  19. }

Which should turn echo off on an AT device, returning 0(numeric) OK(verbose[default]).

OK

Authors

License

This project is licensed under the GNU GPLv3 License. See the LICENSE file for details.

ToDo Tasks

  • Read data into a stream object held by the serial device.
  • Thread protect comm handle.
  • Add Examples / Use cases.
  • Emulate stl iostream.
  • Fix synchronous send/recv.