Skip to content

pizthewiz/Cinder-Serial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cinder-Serial

Cross-platform serial communication CinderBlock thinly wrapping the serial library.

USAGE

// dump all serial ports
for (auto port : SerialPort::getPorts()) {
    console() << port->getName() << endl;
    console() << "descr: " << port->getDescription() << endl;
    console() << "ident: " << port->getHardwareIdentifier() << endl;
}

// find a port
auto port = SerialPort::findPortByNameMatching(std::regex("\\/dev\\/cu\\.usbmodem.*"));

// create a device
auto device = SerialDevice::create(port, 115200);

// read
uint8_t inBuffer[16];
while (device->getNumBytesAvailable() > 0) {
    size_t size = device->readBytes(inBuffer, 16);
}

// write
uint8_t outBuffer[5] = {
    0, 255, 255, // cyan RGB
    '\r', '\n', // EOL
};
device->writeBytes(outBuffer, 5);

SLIP and COBS encode / decode is available separately via the Cinder-Encoding CinderBlock.

GREETZ

About

CinderBlock for cross-platform serial communication

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published