-
Notifications
You must be signed in to change notification settings - Fork 21
Description
Hi,
I'm using this addon for an installation where I'm controlling multiple steppers and servos and it works great if the code where I send the message via serial is inside an event listener function (like mousePressed() or keyPressed() ), but not if I use it inside setup() or update().
To be more precise, this is the code that I'm using to send the osc message via serial (modelled on the OSC-SLIP packet example):
ofxOscMessage osc_message;
osc_message.setAddress("/home");
osc_message.addIntArg(1);
send_osc_bundle(osc_message, cnc_device, 1024);
-
If I only put these 4 lines inside a ofApp::keyPressed(), it works ok. ✅
-
If I instead put them inside ofApp::setup() , after setting up the serial device, it does not work. ❌
-
Finally, if I put them inside ofApp::setup() and also inside ofApp::keyPressed(), even the keyPressed() event doesn't work. ❌
For reference, this is my send_osc_bundle().
//--------------------------------------------------------------
void ofApp::send_osc_bundle(ofxOscMessage &m, ofxIO::SLIPPacketSerialDevice &device, int buffer_size){
// this code comes from ofxOscSender::sendMessage in ofxOscSender.cpp
// static const int OUTPUT_BUFFER_SIZE = buffer_size;
char buffer[buffer_size];
// create the packet stream
osc::OutboundPacketStream p(buffer, buffer_size);
p << osc::BeginBundleImmediate; // start the bundle
append_message(m, p); // add the osc message to the bundle
p << osc::EndBundle; // end the bundle
// send to device
device.send(ofxIO::ByteBuffer(p.Data(), p.Size()));
}
The append_message() is the exact same code of the examples.
Any hint would be great! I've been struggling with this for quite a while.
Thanks!