changeset 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 d358d4410d01
files .cproject core/client.cpp projects/basic_network/render.cpp
diffstat 3 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/.cproject	Fri May 08 11:12:13 2015 +0100
+++ b/.cproject	Fri May 08 17:48:58 2015 +0100
@@ -94,7 +94,7 @@
 					<sourceEntries>
 						<entry excluding="audio_routines_old.S" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="core"/>
 						<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="include"/>
-						<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="projects/analogDigitalDemo"/>
+						<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="projects/basic_network"/>
 						<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="source"/>
 					</sourceEntries>
 				</configuration>
--- 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
--- a/projects/basic_network/render.cpp	Fri May 08 11:12:13 2015 +0100
+++ b/projects/basic_network/render.cpp	Fri May 08 17:48:58 2015 +0100
@@ -19,11 +19,11 @@
 AuxiliaryTask transmitReceiveDataTask;
 
 void transmitReceiveData(){
-	printf("transmitAndReceiveData\n");
+   	printf("transmitReceiveData auxiliary task has started\n");
 	while(!gShouldStop){
-		//sendMessage(networkObject);
-		//receiveMessage(networkObject);
-		usleep(10000);
+		sendMessage(networkObject);
+		receiveMessage(networkObject);
+		usleep(1000);
 	}
 	closeSockets();
 }
@@ -53,7 +53,7 @@
 	networkObject.variables[1]=&gPhase;
 	networkObject.numVariables=2;
 	setupSockets(settings->receivePort, settings->transmitPort, settings->serverName);
-	transmitReceiveDataTask=createAuxiliaryTaskLoop(*transmitReceiveData, 50, "transmit-receive-data");
+	transmitReceiveDataTask=createAuxiliaryTaskLoop(*transmitReceiveData, 80, "transmit-receive-data");
 	//scheduleAuxiliaryTask(transmitReceiveDataTask); //here it does not work
 	return true;
 }