3 Star 6 Fork 7

liushuai / SmartSerial

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

SmartSerial

Build Status Build Status Build Status

简化串口编程 提供方便的接口和严格的线程安全特性

Requirements

  • C++11
  • CMake 3.1

Features

  • 数据自动回调
  • 异常自动重连
  • 自动连接设备 通过串口名、VID_PID
  • 全平台支持: macOS、Linux、Windows
  • 所有方法严格线程安全

Usage

  • clone repository
git clone --recursive https://github.com/shuai132/SmartSerial.git
  • simple usage
#include "SmartSerial.h"

SmartSerial smartSerial("/dev/ttyUSB0");
smartSerial.setOnOpenHandle([](bool isOpen) {
    // handle very likely on other thread
});
smartSerial.setOnReadHandle([](const uint8_t* data, size_t size) {
    // on read data(other thread)
});

smartSerial.write("hello world");

Hardware

任选一种方式

  • 短接Rx与Tx
  • arduino
void setup() {
    Serial.begin(115200);
}

void loop() {
    if (Serial.available()) {
        Serial.write(Serial.read());
    }
}                                         

Other

如果需要对数据打包和解包,可配合下面的库使用:

https://github.com/shuai132/PacketProcessor

空文件

简介

通用串口编程库高层次封装 全平台支持 展开 收起
C++
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C++
1
https://gitee.com/shuai132/SmartSerial.git
git@gitee.com:shuai132/SmartSerial.git
shuai132
SmartSerial
SmartSerial
master

搜索帮助