![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
v3 soft
Fork of SOFT253_Assignment_V3 by
Diff: main.cpp
- Revision:
- 39:f43b008adc9d
- Parent:
- 38:8b6a6927b4f2
- Child:
- 40:4ea91e49d60c
diff -r 8b6a6927b4f2 -r f43b008adc9d main.cpp --- a/main.cpp Sat May 13 00:48:10 2017 +0000 +++ b/main.cpp Sat May 13 19:52:24 2017 +0000 @@ -16,10 +16,10 @@ int humiMax = 100; char cmd[20]; char cmd2[20]; -char s1[20]; -char s11[20]; -char s2[20]; -char s22[20]; +char readAll1[20]; +char readAll11[20]; +char stringToCompare2[20]; +char stringToCompare22[20]; float tempArray[N]; float humArray[N]; float pressArray[N]; @@ -95,38 +95,74 @@ void threadcomun (void const *args) { - int ret; - int ret2; + int res; + int res2; pc.baud(115200); pc.printf("Temperature,Humidity,Pressure\n\n"); //while(cmd==NULL){cmd=getchar();} - while(1){ - scanf("%s%s",&cmd,&cmd2); + while(1) + { + scanf("%s%s",&cmd,&cmd2); - //pc.printf("YOU ENTERED: %s \n",cmd); - strcpy (s1,cmd); - strcpy (s11,cmd2); - strcpy (s2,"READ"); - strcpy (s22,"ALL"); - ret = strncmp(s1,s2,20); - ret = strncmp(s11,s22,20); + //READ ALL------------------------------------------ + //pc.printf("YOU ENTERED: %s \n",cmd); + + + strcpy (readAll1,cmd); //INPUT 1 + strcpy (readAll11,cmd2); //INPUT 2 + strcpy (stringToCompare2,"READ"); //STRING TO COMPARE 1 + strcpy (stringToCompare22,"ALL"); //STRING TO COMPARE 2 + res = strncmp(readAll1,stringToCompare2,20); + res2 = strncmp(readAll11,stringToCompare22,20); - if (ret==0 && ret2==0) - { - + if (res==0 && res2==0) + { for (unsigned int n=0; n<N; n++) { pc.printf("the element of %d is %4.2f\n\r ",n,tempArray[n]); - - // wait(1.0); - } + // wait(1.0); + } } else - { - pc.printf("error re mlk: %s\n",cmd); - } - } + { + strcpy (stringToCompare2,"DELETE"); + strcpy (stringToCompare22,"ALL"); + res = strncmp(readAll1,stringToCompare2,20); + res2 = strncmp(readAll11,stringToCompare22,20); + + if(res==0 && res2==0) + { + //Delete every element. + memset(tempArray, 0, sizeof tempArray); + pc.printf("%d Elements deleted\n",N); + } + else + { + strcpy (stringToCompare2,"READ"); + strcpy (stringToCompare22,"Kapoion arithmo"); + res = strncmp(readAll1,stringToCompare2,20); + res2 = strncmp(readAll11,stringToCompare22,20); + + if(res==0 && res2==0) + { + + } + } + } + + + + + + //switch(cmd) + //{ + // case 'f': pc.printf("Douleuei"); + //} + + + + }//End of while } char answer;