Skip to content

KirillHit/serial_port

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

linux_serial_port

Library for managing Linux serial ports. It is based on the CppLinuxSerial library.

Example

#include <string>

#include "serial_port/serial_port.hpp"


int main()
{
    serial::SerialPort port("/dev/ttyS2");

    serial::ttyConfig config {
        .baudRate = serial::BaudRate::B_115200,
        .numDataBits = serial::NumDataBits::EIGHT,
        .numStopBits = serial::NumStopBits::ONE,
        .parity = serial::Parity::NONE,
        .hardwareFlowControl = serial::HardwareFlowControl::OFF,
        .softwareFlowControl = serial::SoftwareFlowControl::OFF,
        .vtime = 10,
        .vmin = 0
    };

    port.set_config(config);
    port.open();

    port.write("Hello");

    std::string answer;
    port.read(answer);

    port.close();

    return 0;
}

References

Linux Serial Ports Using C/C++

Terminal Modes

About

Library for managing Linux serial ports

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published