void serverCommunication() { int strlength; char msg[5]; while (1) { strlength=recv(client_socket,msg,5,0); msg[strlength]='\0'; printf("Received message: %s\n",msg); if (strcmp(msg,AREYOUACTIVE)) { if (strcmp(msg,"")==0) { close(client_socket); printf("server fail!\n"); exit(1); } if (strcmp(msg,PROGRAMM_RED)==0) { printf("I will follow RED!\n"); mission=RED; } if (strcmp(msg,PROGRAMM_YELLOW)==0) { printf("I will follow YELLOW!\n"); mission=YELLOW; } if (strcmp(msg,PROGRAMM_GREEN)==0) { printf("I will follow GREEN!\n"); mission=GREEN; } if (strcmp(msg,PROGRAMM_BLUE)==0) { printf("I will follow BLUE!\n"); mission=BLUE; } if (strcmp(msg,PROGRAMM_FRONT)==0) { printf("I will drive in front\n"); mission=FRONT; } } else //occurs regularly { if ((power_level()<MIN_CBC_VOLTAGE)||(create_charge<MIN_CREATE_CHARGE)) { send(client_socket,INACTIVE,sizeof(INACTIVE),0); mission=CHARGE; } else { send(client_socket,ACTIVE,sizeof(ACTIVE),0); } } } }
int main (int argc, char * argv[]) { int value = power_level (); if (value < 9000) { printf ("Power level is %i\n", value); return 1; } printf ("IT'S OVER 9000!!!\n"); return 0; }
int main(int argc, char* argv[]) { printf("power level = %f\n", power_level()); return 0; }