The problem was in the receiving end of the SLIP packets, on the Teensy.
I had 'if(!msgIN.hasError())' inside the loop: 'while(!SLIPSerial.endofPacket())'
What happened was that the OSC message was being filled up, and when the address of the message was filled in msgIN.hasError() no longer gave an error.
Therefore msgIN.route() invoked the function matching the OSC message address before any value was filled in to the message.
The solution was to move 'if(!msgIN.hasError())' outside of the while loop, and everything worked like a charm!
This code worked:
void OSCMsgReceive()
{
OSCMessage msgIN;
int size;
static unsigned long microsTime = 0;
while (!SLIPSerial.endofPacket())
{
if ((size = SLIPSerial.available()) > 0)
{
microsTime = micros();
while (size--) //this needs a byte limit
{
msgIN.fill(SLIPSerial.read());
}
}
if ((micros() - microsTime) > 10000) break; //Timeout for no eoP()
}
if(!msgIN.hasError())
{
//msgIN.route("/OnOff/toggle1",toggleOnOff);
msgIN.route("/Fader/Value",funcValue);
//msgIN.route("/XY/xy",xy);
}
}
The original code that did NOT work:
void OSCMsgReceive()
{
OSCMessage msgIN;
int size;
while(!SLIPSerial.endofPacket())
{
if((size = SLIPSerial.available()) > 0)
{
while(size--)
{
msgIN.fill(SLIPSerial.read());
}
if(!msgIN.hasError())
{
msgIN.route("/OnOff/toggle1",toggleOnOff);
msgIN.route("/Fader/Value",funcValue);
msgIN.route("/XY/xy",xy);
}
}
}
}