Feature Request: Add Processing's Serial library ability to read strings in OpenFrameworks Serial

Currently when using OF serial you need to deal with Serial Bytes and convert that into a usable number.

This unfortunately is a bit complicated to quickly get projects going or to transfer from Processing to OF.

I am requesting a function added to OpenFrameworks Serial to read in Serial Print string statements like Processing: https://processing.org/reference/libraries/serial/Serial_read_.html

This is Processing’s Serial source code(java): https://github.com/processing/processing/blob/349f413a3fb63a75e0b096097a5b0ba7f5565198/java/libraries/serial/src/processing/serial/Serial.java

ofxSerial has this capability built in.

see readStringUntil().

If you want the exact processing-like behavior you can use

std::size_t readBytes(std::string& buffer) const;

e.g.

std::string buffer;
std::size_t bytesRead = serial.readBytes(buffer);

// or 

buffer = serial.readStringUntil('\n'); // or whatever character you like.


For more sophisticated event-buffer-based handling, see this example:

1 Like