Skip to content
CinderBlock for cross-platform serial communication
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
include
lib
samples/ColorPicker
src
.gitignore
.gitmodules
LICENSE
README.md
TODO.md
cinderblock.xml

README.md

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

You can’t perform that action at this time.