I am noticing that when ever I receive a serial signal with ofxSerial from my Arduino in
void onSerialBuffer(const ofxIO::SerialBufferEventArgs& args){
}
my app freezes for a split second.
Is there a way to make this event non-blocking?
Thanks for any advice.
Here the whole function:
void onSerialBuffer(const ofxIO::SerialBufferEventArgs& args){
// Buffers will show up here when the marker character is found.
ofLog()<<"serial args.buffer() "<<args.buffer();
vector<string> splitStr = ofSplitString(args.buffer().toString(), ":");
if(splitStr[0] == "s"){
//states
ofLog()<<"serial state:"<<splitStr[1] <<" splitStr[2] "<<splitStr[2];
if(ofIsStringInString(splitStr[1], "upper")){
upperSwitchState_str = splitStr[2];
if(splitStr[2] == "ON"){
upperSwitchState = true;
} else {
upperSwitchState = false;
}
} else if(ofIsStringInString(splitStr[1], "lower")){
lowerSwitchState_str = splitStr[2];
if(splitStr[2] == "ON"){
lowSwitchState = true;
} else {
lowSwitchState = false;
}
}
} else if(splitStr[0] == "i"){
//info
ofLog()<<"serial info:"<<splitStr[1];
} else if(splitStr[0] == "a"){
//alive
aliveTimer = ofGetElapsedTimef();
aliveCounter = ofToInt(splitStr[1]);
} else {
}
}