ofxSerial problem on Raspberry Pi 4 Buster Lite

Hi there,

I’ve been coding an installation for which I have a Teensy 4.0 (arduino-like thing) hooked up through FTDI drivers to a RaspBerry Pi 4 USB2 port. Because I already had some problems with the ofSerial class I decided to switch the communication to ofxSerial. Now all is fine when I just constant stings, but I need to ‘create’ the string dynamically as I’m sending over different pixel data. When I do this, my functions stop working. They might send a couple times, but after that communication is just halted. I feel like I’m looking over something…

Function that constructs the message;

void Comm::sendPixel(ofx::IO::SerialDevice& serial, int socket_index, std::shared_ptr<Pixel> pixel, unsigned int channel_idx) {
    std::string message = "I,PC," + std::to_string(pixel->index);
    sendPackage(serial, socket_index, message);
}

Sending function;

void Comm::sendPackage(ofx::IO::SerialDevice& serial, int socket_index, std::string message) {
    std::string msg = message;
    std::string idx = std::to_string(socket_index);
    ofx::IO::ByteBuffer socketBuffer(idx);
    ofx::IO::ByteBuffer messageBuffer(message);

    if (serial.isOpen()) {
        serial.writeByte(startMarker_);
        serial.writeBytes(socketBuffer);
        serial.writeByte(',');
        serial.writeBytes(messageBuffer);
        serial.writeByte(endMarker_);
        serial.writeByte('\n');
        serial.flush();
        serial.flushInput();
        serial.flushOutput();
    }
}

Currently I’m flushing everything as I was hopelessly trying to debug the thing the whole day. I detect begin & ends of messages by using beginmarker and endmarkers (’<’ and ‘>’) so the ‘\n’ isnt needed but gives some extra safety.

The use of ofxSerial here is based on the example at; https://github.com/bakercp/ofxSerial/blob/master/examples/basic/echo/src/ofApp.cpp

Any recommendations? I really feel like it has to do with the string that is constructed. Basically tried everything else.

Maybe send the message to the Teensy and have it send whatever it recieves back to the OF app. Then you can see if it gets any thing.