summaryrefslogtreecommitdiff
path: root/Libraries/OSC/OSCDecoder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries/OSC/OSCDecoder.cpp')
-rw-r--r--Libraries/OSC/OSCDecoder.cpp103
1 files changed, 17 insertions, 86 deletions
diff --git a/Libraries/OSC/OSCDecoder.cpp b/Libraries/OSC/OSCDecoder.cpp
index 0784851..4a75179 100644
--- a/Libraries/OSC/OSCDecoder.cpp
+++ b/Libraries/OSC/OSCDecoder.cpp
@@ -1,16 +1,16 @@
/*
-
+
ArdOSC - OSC Library for Arduino.
-
+
-------- Lisence -----------------------------------------------------------
-
+
ArdOSC
-
+
The MIT License
-
+
Copyright (c) 2009 - 2010 recotana( http://recotana.com ) All right reserved
-
- */
+
+ */
#include <stdlib.h>
#include <string.h>
@@ -21,16 +21,16 @@
int16_t OSCDecoder::decode( OSCMessage::OSCMessage *mes ,const uint8_t *recData ){
-
-
+
+
//=========== BIN -> OSC Address(String) Decode ===========
-
+
const uint8_t *packStartPtr=recData;
-
+
mes->setOSCAddress((char*)packStartPtr);
-
+
packStartPtr += mes->oscAdrPacSize;
-
+
//=========== BIN -> TypeTag (String) Decode ===========
@@ -41,78 +41,9 @@ int16_t OSCDecoder::decode( OSCMessage::OSCMessage *mes ,const uint8_t *recData
//=========== BIN -> Auguments Decode ===========
-
-
- if (mes->arguments!=NULL) free(mes->arguments);
- mes->arguments=(void**)calloc(mes->argsNum, sizeof(void*));
-
- mes->argsPacSize=0;
-
- uint8_t *tmpPtr;
- uint16_t tmpSize;
-
-
-
- for (uint16_t i=0; i< mes->argsNum ; i++) {
-
- switch (mes->typeTag[i]) {
-
- case 'i':
-
- tmpPtr=(uint8_t*)calloc(1, 4);
-
- *(tmpPtr+3)=*(uint8_t*)packStartPtr++;
- *(tmpPtr+2)=*(uint8_t*)packStartPtr++;
- *(tmpPtr+1)=*(uint8_t*)packStartPtr++;
- *tmpPtr=*(uint8_t*)packStartPtr++;
-
- mes->arguments[i]=(uint32_t*)tmpPtr;
- mes->argsPacSize += 4;
- break;
-
-#ifdef _USE_FLOAT_
- case 'f':
-
- tmpPtr=(uint8_t*)calloc(1, 4);
-
- *(tmpPtr+3)=*(uint8_t*)packStartPtr++;
- *(tmpPtr+2)=*(uint8_t*)packStartPtr++;
- *(tmpPtr+1)=*(uint8_t*)packStartPtr++;
- *tmpPtr=*(uint8_t*)packStartPtr++;
-
- mes->arguments[i]=(float*)tmpPtr;
- mes->argsPacSize += 4;
-
- break;
-#endif
-
-
-#ifdef _USE_STRING_
- case 's':
-
- tmpSize=strlen((char*)packStartPtr);
-
- if(tmpSize > kMaxStringCharactor){
-
- DBG_LOGLN("decode max str err");
- return 1;
- }
-
-
- tmpPtr=(uint8_t*)calloc(tmpSize+1, 1);
- strcpy((char*)tmpPtr,(char*)packStartPtr);
-
- mes->arguments[i]=tmpPtr;
-
-
- tmpSize = mes->getPackSize(tmpSize);
- packStartPtr += tmpSize;
- mes->argsPacSize += tmpSize;
-
- break;
-#endif
- }
- }
-
+
+ mes->argStart = packStartPtr;
+ mes->argsPacSize=mes->argsNum * 4;
+
return 0;
}