Skip to content

Ocanath/serial-cross-platform

Repository files navigation

Serial Cross-Platform Library

A lightweight, cross-platform C++ library for serial communication that works on Windows, Linux, and macOS.

Features

  • Cross-platform: Single codebase for Windows, Linux, and macOS
  • Simple API: Easy-to-use interface for serial communication
  • Auto-detection: Automatically find and connect to available serial ports
  • Manual connection: Connect to specific ports with custom baud rates
  • Header-only ready: Minimal dependencies

Requirements

  • CMake 3.10 or higher
  • C++17 compatible compiler
  • Windows: Visual Studio 2017+ or MinGW
  • Linux: GCC 7+ or Clang 5+
  • macOS: Xcode 9+ or Clang 5+

Building the Library

Prerequisites

Make sure you have CMake installed on your system:

  • Windows: Download from cmake.org or use choco install cmake
  • Linux: sudo apt-get install cmake (Ubuntu/Debian) or sudo yum install cmake (CentOS/RHEL)
  • macOS: brew install cmake or download from cmake.org

Build Instructions

After cloning, you can build the project with cmake. You must initialize all subomdules after the inital clone or the build will fail:

git submodule update --init --recursive

Then

cmake -B build
cmake --build build

Troubleshooting

Common Issues

  1. Permission denied (Linux/macOS)

    # Add user to dialout group (Linux)
    sudo usermod -a -G dialout $USER
    # Log out and back in, or run:
    newgrp dialout
  2. Port not found

    • Check if device is properly connected
    • Verify port name is correct for your platform
    • Try using autoconnect() to find available ports
  3. Build errors

    • Ensure CMake version is 3.10 or higher
    • Check that C++17 compiler is available
    • On Windows, make sure you have Visual Studio or MinGW installed

About

Cross platform C++ serial library for Linux and Windows

Resources

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors