#include #include #include #include // you can find this written on the board of some Arduino Ethernets or shields byte mac[] = { 0x90, 0xA2, 0xDA, 0x0E, 0xC5, 0x3C }; int serverPort = 8000; //TouchOSC (incoming port) int destPort = 9000; //TouchOSC (outgoing port) //Create UDP message object EthernetUDP Udp; void setup(){ Serial.begin(9600); //9600 for a "normal" Arduino board (Uno for example). 115200 for a Teensy ++2 Serial.println("OSC test"); if (Ethernet.begin(mac) == 0) { Serial.println("Failed to configure Ethernet using DHCP"); // no point in carrying on, so do nothing forevermore: while(true); } // print your local IP address: Serial.print("Arduino IP address: "); for (byte thisByte = 0; thisByte < 4; thisByte++) { // print the value of each byte of the IP address: Serial.print(Ethernet.localIP()[thisByte], DEC); Serial.print("."); } Serial.println(); Udp.begin(serverPort); } void loop(){ //process received messages OSCMsgReceive(); } void OSCMsgReceive(){ OSCMessage msgIN; int size; if((size = Udp.parsePacket())>0){ while(size--) msgIN.fill(Udp.read()); Serial.print("msgIN.size "); Serial.println(msgIN.bytes()); if(!msgIN.hasError()){ msgIN.route("/1/fdr_RED_01",osc_dmx); msgIN.route("/1/fdr_GRN_01",osc_dmx); } } } void osc_dmx(OSCMessage &msg, int addrOffset){ char addrChar[24]; // char to store the OSC address int addressLength = msg.getAddress(addrChar, addrOffset); //fills addrChar ////////////////////////////////HERE ARE MY ATTEMPTS AT PATTERN MATCHING, I've tried match() and fullMatch()//////////////////////////// //if (msg.fullMatch("/1", addrOffset)){ //if (msg.fullMatch("/1/fdr_RED_01", addrOffset)){ if (msg.match("/1", addrOffset)){ Serial.println("We've got a match!"); } for (int i = 0; i <= 23; i++){ Serial.print(addrChar[i],HEX); Serial.print(","); } Serial.println("END HEX"); /* for (int i = 0; i <= 23; i++){ Serial.print(byte(addrChar[i])); Serial.print(","); } Serial.println("END BYTE"); */ float value = msg.getFloat(0); // get the value Serial.print("value "); Serial.println(value); //dmx_master.setChannelValue(channel, value); //output to DMX }