support OSC-string

Dependents:   OSCtoCVConverter

Fork of OSC by Toby Harris

Files at this revision

API Documentation at this revision

Comitter:
casiotone401
Date:
Tue Mar 08 11:50:30 2016 +0000
Parent:
7:498455cded21
Commit message:
minor change

Changed in this revision

mbedOSC.cpp Show annotated file Show diff for this revision Revisions of this file
mbedOSC.h Show annotated file Show diff for this revision Revisions of this file
diff -r 498455cded21 -r 73bce95a6853 mbedOSC.cpp
--- a/mbedOSC.cpp	Thu Feb 25 11:21:27 2016 +0000
+++ b/mbedOSC.cpp	Tue Mar 08 11:50:30 2016 +0000
@@ -96,7 +96,7 @@
         index = argNum;  
     }
 
-    return recArgs[index].i;
+    return oscArgs[index].i;
 }
  
  
@@ -107,7 +107,7 @@
         index = argNum;  
     }
     
-    return recArgs[index].f;
+    return oscArgs[index].f;
 }
 
 double OSCMessage::getArgDouble(uint8_t index) {
@@ -117,7 +117,7 @@
         index = argNum;  
     }
     
-    return recArgs[index].d;
+    return oscArgs[index].d;
 }
 
 char * OSCMessage::getArgString(uint8_t index) {
@@ -127,7 +127,7 @@
         index = argNum;  
     }
     
-    return recArgs[index].s;
+    return oscArgs[index].s;
 }
  
 //-------------------------------------------------
@@ -215,19 +215,19 @@
         switch(types[i]) {
             
             case 's':
-                sendArgs[i].s = va_arg(argList, char *);
+                oscArgs[i].s = va_arg(argList, char *);
                 break;
  
             case 'i':
-                sendArgs[i].i = va_arg(argList, int);
+                oscArgs[i].i = va_arg(argList, int);
                 break;
  
             case 'f':
-                sendArgs[i].f = va_arg(argList, double);
+                oscArgs[i].f = va_arg(argList, double);
                 break;
             
             case 'd':
-                sendArgs[i].d = va_arg(argList, double);
+                oscArgs[i].d = va_arg(argList, double);
                 break;
                 
             default:
@@ -404,7 +404,7 @@
             
             case 's':
                 
-                receiverMessage->recArgs[i].s = (char *)tempArg[i];
+                receiverMessage->oscArgs[i].s = (char *)tempArg[i];
                 break;
  
             case 'i':
@@ -415,7 +415,7 @@
                 } ui;
                 
                 memcpy(ui.b, tempArg[i], 4);
-                receiverMessage->recArgs[i].i = ui.i;
+                receiverMessage->oscArgs[i].i = ui.i;
                 break;
  
             case 'f':
@@ -426,7 +426,7 @@
                 } uf;
             
                 memcpy(uf.b, tempArg[i], 4);
-                receiverMessage->recArgs[i].f = uf.f;
+                receiverMessage->oscArgs[i].f = uf.f;
                 break;
             
             case 'd':
@@ -437,7 +437,7 @@
                 } ud;
         
                 memcpy(ud.b, tempArg[i], 8);
-                receiverMessage->recArgs[i].d = ud.d;
+                receiverMessage->oscArgs[i].d = ud.d;
                 break;
                 
             default:
@@ -502,18 +502,16 @@
     }
     
     //3) add argument values (Note: here only big endian):
-    uint8_t *v;
     
     for (i = 0; i < sendContainer->argNum; ++i) {
         
         switch (sendContainer->typeTag[i])
         {
             case 's':
-                v = (uint8_t *)sendContainer->sendArgs[i].s;
     
-                while (v[j] != '\0') {
+                while (sendContainer->oscArgs[i].s[j] != '\0') {
         
-                    buff[lengthEnd++] = v[j++];
+                    buff[lengthEnd++] = sendContainer->oscArgs[i].s[j++];
                 }
     
                 // pad with 0s to align in multiples of 4:
@@ -529,34 +527,22 @@
                 break;
 
             case 'i':
-                v = (uint8_t *)&sendContainer->sendArgs[i].i;
-    
-                buff[lengthEnd++] = v[3];
-                buff[lengthEnd++] = v[2];
-                buff[lengthEnd++] = v[1];
-                buff[lengthEnd++] = v[0];
-                break;
-        
             case 'f':
-                v = (uint8_t *)&sendContainer->sendArgs[i].f;
-    
-                buff[lengthEnd++] = v[3];
-                buff[lengthEnd++] = v[2];
-                buff[lengthEnd++] = v[1];
-                buff[lengthEnd++] = v[0];
+                buff[lengthEnd++] = sendContainer->oscArgs[i]._b[3];
+                buff[lengthEnd++] = sendContainer->oscArgs[i]._b[2];
+                buff[lengthEnd++] = sendContainer->oscArgs[i]._b[1];
+                buff[lengthEnd++] = sendContainer->oscArgs[i]._b[0];
                 break;
         
             case 'd':
-                v = (uint8_t *)&sendContainer->sendArgs[i].d;
-    
-                buff[lengthEnd++] = v[7];
-                buff[lengthEnd++] = v[6];
-                buff[lengthEnd++] = v[5];
-                buff[lengthEnd++] = v[4];
-                buff[lengthEnd++] = v[3];
-                buff[lengthEnd++] = v[2];
-                buff[lengthEnd++] = v[1];
-                buff[lengthEnd++] = v[0];
+                buff[lengthEnd++] = sendContainer->oscArgs[i]._b[7];
+                buff[lengthEnd++] = sendContainer->oscArgs[i]._b[6];
+                buff[lengthEnd++] = sendContainer->oscArgs[i]._b[5];
+                buff[lengthEnd++] = sendContainer->oscArgs[i]._b[4];
+                buff[lengthEnd++] = sendContainer->oscArgs[i]._b[3];
+                buff[lengthEnd++] = sendContainer->oscArgs[i]._b[2];
+                buff[lengthEnd++] = sendContainer->oscArgs[i]._b[1];
+                buff[lengthEnd++] = sendContainer->oscArgs[i]._b[0];
                 break;
 
             default:
diff -r 498455cded21 -r 73bce95a6853 mbedOSC.h
--- a/mbedOSC.h	Thu Feb 25 11:21:27 2016 +0000
+++ b/mbedOSC.h	Tue Mar 08 11:50:30 2016 +0000
@@ -66,11 +66,12 @@
             int     i;
             float   f;
             double  d;
+            
+            char _b[8]; // endian conversion temp variable
            
         } OSCArg;
         
-        OSCArg sendArgs[MAX_ARG];
-        OSCArg recArgs[MAX_ARG];
+        OSCArg oscArgs[MAX_ARG];
         
         uint8_t     argNum;