osc from OF to arduino

Hi,
I’m trying to send OSC messages from OF to an arduino using the ardOSC library on the arduino side and ofxOsc in OF.
I’m creating single messages not bundle but when I send them to the arduino and print what the arduino receives through serial instead of the message address I get #bundle.
Did anyone experienced the same situation and could explain me what’s going on ?
If I send the same message from OF to SuperCollider I get the right address for the message.

E

1 Like

Sorry, I think I’m following along but it might help if you post your code? I’ve never used ardOSC but I could probably help if you post things up here.

hello

i know this is an old topic and you have probably solved it yourself already. I just had the same problem with the ofxOsc-Addon and the Arduino OSC-library. Basically the Arduino side doesn’t support OSC-Bundles. The ‘#bundle’ you get is the header for an osc-bundle (see http://opensoundcontrol.org/spec-1-0 ). The arduino-library interprets this as the osc-address wich is not correct.

ofxOSC for some reason creates OSC-Bundles even for simple messages. This is in ofxOscSender.cpp, ofxOscSender::sendMessage(). So if you comment out line 82 & 84 it will stop doing that. But as i don’t know why every message is packet into a bundle in the first place, i’m not sure what other implications this will have. BUT it will make it work with the arduino (Z_OSC library, https://github.com/djiamnot/Z-OSC in my case).

  
void ofxOscSender::sendMessage( ofxOscMessage& message )  
{  
	static const int OUTPUT_BUFFER_SIZE = 16384;  
	char buffer[OUTPUT_BUFFER_SIZE];  
    osc::OutboundPacketStream p( buffer, OUTPUT_BUFFER_SIZE );  
  
	// serialise the message  
	//p << osc::BeginBundleImmediate;  
	appendMessage( message, p );  
	//p << osc::EndBundle;  
  
	socket->Send( p.Data(), p.Size() );  
}  

cheers,
extra

3 Likes

solid gold, saved my life today!

hm, it would seem appropriate to report a bug against Z_OSC. bundles are a part of the OSC spec, after all…
edit: ah great, there is already a bug report: https://github.com/recotana/ArdOSC/issues/3

1 Like

you save me ! :slight_smile: thanks!

1 Like

Even my version of OpenFrameWorks has this kind of “fix” this is only working only after comment the ifs

void ofxOscSender::sendMessage(const ofxOscMessage &message, bool wrapInBundle){
	if(!sendSocket){
		ofLogError("ofxOscSender") << "trying to send with empty socket";
		return;
	}
	
	// setting this much larger as it gets trimmed down to the size its using before being sent.
	// TODO: much better if we could make this dynamic? Maybe have ofxOscMessage return its size?
	static const int OUTPUT_BUFFER_SIZE = 327680;
	char buffer[OUTPUT_BUFFER_SIZE];
	osc::OutboundPacketStream p(buffer, OUTPUT_BUFFER_SIZE);

	// serialise the message and send
//	if(wrapInBundle) {
//		p << osc::BeginBundleImmediate;
//	}
	appendMessage(message, p);
//	if(wrapInBundle) {
//		p << osc::EndBundle;
//	}
	sendSocket->Send(p.Data(), p.Size());
}

Now it is working!! Thank you guys! Saved me here!

are you using latest release? I think this was changed in github by this PR

2 Likes

Hey @dimitre thanks for the reply. Well, I’ve downloaded what was the last version (of_v0.11.2_osx_release) but i’ve just checked and my wrapInBundle is set to default True.

I will change the default to False and return the ifs to the code.

Thank you!!

maybe it is fixed already in nightly builds