Mercurial > hg > beaglert
diff core/client.cpp @ 25:98aed580452a bbb_network
- Network now actually works.
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Fri, 08 May 2015 17:48:58 +0100 |
parents | ad5cd8dd99b3 |
children | 12ee9a61e81d |
line wrap: on
line diff
--- a/core/client.cpp Fri May 08 11:12:13 2015 +0100 +++ b/core/client.cpp Fri May 08 17:48:58 2015 +0100 @@ -80,7 +80,7 @@ FD_ZERO(&stReadFDS); // Timeout of one second stTimeOut.tv_sec = 0; - stTimeOut.tv_usec = 1000; + stTimeOut.tv_usec = 0; FD_SET(inSock, &stReadFDS); int t = select(inSock+1, &stReadFDS, NULL, NULL, &stTimeOut); @@ -101,11 +101,11 @@ //the worst parser ever int previousN=0; int currentVariable=0; - for(int n=0; inBuffer[n]!=0 && currentVariable<message.numVariables && n-previousN<MAX_VAR_STRING;n++){ //scan the string - if(inBuffer[n]==';'||n==0){ // if you find a separator or you are at the end of the string, parse the variable + for(int n=0; inBuffer[n]!=0 && currentVariable<message.numVariables && n-previousN<MAX_VAR_STRING && n<BUFF_LEN; n++){ //scan the string + if(inBuffer[n]==';'||inBuffer[n]==0||inBuffer[n]=='\n'){ // if you find a separator or you are at the end of the string, parse the variable int j=0; inBuffer[n]=0; //set the semicolon to 0 ... - while( (variableString[j++]=inBuffer[previousN++]) ); // ... so that this will stop when it gets there + while( (variableString[j++]=inBuffer[previousN++]) );; // ... so that this will stop when it gets there rt_printf("variable %d: %s\n", currentVariable, variableString); *(message.variables[currentVariable])=atof(variableString); n++; //increment to step after the semicolon