开源软件名称(OpenSource Name):gbmhunter/CppLinuxSerial开源软件地址(OpenSource Url):https://github.com/gbmhunter/CppLinuxSerial开源编程语言(OpenSource Language):C++ 49.0%开源软件介绍(OpenSource Introduction):CppLinuxSerialLinux serial port library written in C++. DescriptionLibrary for communicating with COM ports on a Linux system.
InstallationLinux, MacOS, Windows
Examples#include <CppLinuxSerial/SerialPort.hpp>
using namespace mn::CppLinuxSerial;
int main() {
// Create serial port object and open serial port at 57600 buad, 8 data bits, no parity bit, and one stop bit (8n1)
SerialPort serialPort("/dev/ttyUSB0", BaudRate::B_57600, NumDataBits::EIGHT, Parity::NONE, NumStopBits::ONE);
// Use SerialPort serialPort("/dev/ttyACM0", 13000); instead if you want to provide a custom baud rate
serialPort.SetTimeout(-1); // Block when reading until any data is received
serialPort.Open();
// Write some ASCII data
serialPort.Write("Hello");
// Read some data back (will block until at least 1 byte is received due to the SetTimeout(-1) call above)
std::string readData;
serialPort.Read(readData);
// Close the serial port
serialPort.Close();
} If the above code was in a file called g++ main.cpp -lCppLinuxSerial For more examples, see the files in IssuesSee GitHub Issues. FAQ
ChangelogSee CHANGELOG.md. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论