Skip to content

NodeppOfficial/nodepp-serial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Serial Port Communication for Nodepp Applications

nodepp-serial is a powerful and easy-to-use library that brings robust serial port communication capabilities to your Nodepp applications. Leveraging Nodepp's asynchronous architecture, nodepp-serial allows you to interact with serial devices seamlessly, making it ideal for IoT, embedded systems, and hardware control projects developed with Nodepp.

Key Features:

  • Asynchronous Operations: Fully integrated with Nodepp's event loop for non-blocking serial port access.
  • Cross-Platform: Designed to work across various operating systems supported by Nodepp.
  • Simple API: An intuitive and Node.js-like API for opening, closing, reading from, and writing to serial ports.
  • Event-Driven: Emits events for data reception, errors, and port status changes, simplifying event handling.

Example

#include <nodepp/nodepp.h>
#include <serial/serial.h>

using namespace nodepp;

void onMain(){

    auto device = serial::get_devices();

    if( device.empty() ){ 
        process::error("Not Serial Device Found"); 
    } else {
        console::log( device[0] );
    }

    serial::connect( device[0], 9600 )
    
    .then([]( serial_t cli ){

        console::done( "connected" );

        cli.onData([]( string_t chunk ){
            console::log( chunk );
        });

        stream::pipe( cli );

    })

    .fail([=]( except_t err ){
        console::log( "something went wrong" );
        console::error( err );
    });

}

Compilation

g++ -o main main.cpp -I ./include ; ./main

About

Serial Port Communication for Nodepp Applications

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published