# Unpacking

This can be done in a node dispatch routine. Variables of note:

- osc\_message\_in\_argc : how many arguments in the typetag section
- osc\_message\_in\_len : total message length
- p\_osc_message\_in : pointer to start of message
- p\_osc_message\_in\_tt : pointer to start of typetags (after magic comma)
- p\_osc_message\_in\_data : pointer to start of data section

For figuring out which method was matched in a large tree of nodes:

- osc\_match\_depth : depth of tree at match
- osc\_match\_index : offset of match at each depth
Also, the index of the current depth match is the first argument to the dispatch method (byte i)

Example code from TTL module (simplified):


void oscNodeTTLControl(byte i) {

if(i == 0) {
if(osc_message_in_argc == 1) {
v = oscUnpackBoolean();
if(v == 1 && ttl_enabled == 0) {
ttl_enabled = 1;

// actually enable the hardware feature here...
OpenUSART(...);

} else if(v == 0 && ttl_enabled == 1) {

// turn off the hardware feature here...
CloseUSART();

ttl_enabled = 0;

}
}
}

# Packing

Sending OSC messages is extremely easy, but is less simple than in a high-level language implementation. The address and typetag strings must be formatted by hand.

Example, reports TTL enabled status back to user:

oscMessageOpen();
oscPackROMString("/ttl/enable");
oscPackROMString(",i");
oscPackUnsignedInt8(ttl_enabled);
oscMessageClose();