Yes,
im am sending a string like following from arduino. Thats works fine:
String index = String(1);
String val = String(random(1024));
Serial.print(index + "," + val);
Serial.println("");
But when spliting this to get the single values and put them into a vector I am having segmentation errors.
Here is the collected OF code:
vector<int> values;
values.resize(100);
for(int i = 0; i < values.size(); i++){
values[i] = 0; // set value using index
}
void ofApp::onSerialBuffer(const ofx::IO::SerialBufferEventArgs& args)
{
// Buffers will show up here when the marker character is found.
//SerialMessage message(args.getBuffer().toString(), "", 500);
vector<string> result = ofSplitString(args.getBuffer().toString(),",");
if(ofToInt(result[0]) < values.size()){
if(ofToInt(result[1]) < 1024){
values[ofToInt(result[0])] = ofToInt(result[1]);
}
}
//cout << values[1] << endl;
//serialMessages.push_back(message);
}