CNMAT / OSC

OSC: Arduino and Teensy implementation of OSC encoding
cnmat.berkeley.edu/oscuino
Other
727 stars 135 forks source link

Issue with the [ ] and { } pattern-matching on RPI pico W #135

Open nordseele opened 1 year ago

nordseele commented 1 year ago

Hi,

I'm trying to figure out why I can't get the pattern matching and especially the "wildcards" to work properly. FWIW, I'm on a RPI Pico W w/ Earle Philower Arduino Pico, Arduino core for RP2040.

I've tried with .match, .route and .dispatch I can only traverse hardcoded addresses like the following ones:

msg.match("/er301/*);

Note that the * does work. Something like the pattern below will work:

    if (msg.match("/*/hello/*/world")) {
        OSC_debug(msg);
      }

But absolutely no chance with { } and [ ] and that's my issue here.

I can't traverse the following pattern for example:

msg.route("/{er301,txo}/[1-4]/fct/*", OscDebug);

This full simplified example won't work either ; when sending /er301/42 or /txo/42 from Max, I can't match any message and reach my OscDebug callback function :

void loop() {
  OSCMessage msg;
  int size = Udp.parsePacket();

  if (size > 0) {
    while (size--) {
      msg.fill(Udp.read());
    }
    if (!msg.hasError()) {
      if (msg.match("/{er301,txo}/*")) {
        OSC_debug(msg);
      }

    } else {
      error = msg.getError();
      Serial.print("error: ");
      Serial.println(error);
    }
  }
}

Am I missing something ? I used quite complex pattern-matching with another OSC library, unfortunately it's not flexible enough and I'd rather use the CNMAT library. If I can't get the pattern matching function working, I guess I could always match "step by step" each element of the address...

Any help appreciated, thanks! :-)

adrianfreed commented 10 months ago

you can't match on wild cards. You send wild cards that are matched with the match string