void initStruct(void) { int err; /* Creation des mutex */ if (err = rt_mutex_create(&mutexEtat, NULL)) { rt_printf("Error mutex create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_mutex_create(&mutexMove, NULL)) { rt_printf("Error mutex create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_mutex_create(&mutexRobot, NULL)) { rt_printf("Error mutex create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_mutex_create(&mutexServer, NULL)) { rt_printf("Error mutex create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_mutex_create(&mutexArene, NULL)) { rt_printf("Error mutex create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_mutex_create(&mutexImage, NULL)) { rt_printf("Error mutex create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_mutex_create(&mutexPositionRobot, NULL)) { rt_printf("Error mutex create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_mutex_create(&mutexPositionVoulue, NULL)) { rt_printf("Error mutex create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_mutex_create(&mutexValidArene, NULL)) { rt_printf("Error mutex create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } /* Creation des semaphores */ if (err = rt_sem_create(&semConnecterRobot, NULL, 0, S_FIFO)) { rt_printf("Error semaphore create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_sem_create(&semWatchdog, NULL, 0, S_FIFO)) { rt_printf("Error semaphore create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_sem_create(&semPosition, NULL, 0, S_FIFO)) { rt_printf("Error semaphore create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_sem_create(&semAcquArene, NULL, 0, S_FIFO)) { rt_printf("Error semaphore create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_sem_create(&semValidArene, NULL, 0, S_FIFO)) { rt_printf("Error semaphore create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_sem_create(&semBattery, NULL, 0, S_FIFO)) { rt_printf("Error semaphore create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_sem_create(&semWebcam, NULL, 0, S_FIFO)) { rt_printf("Error semaphore create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_sem_create(&semMission, NULL, 0, S_FIFO)) { rt_printf("Error semaphore create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } /* Creation des taches */ if (err = rt_task_create(&tcommunicate, NULL, 0, PRIORITY_TCOMMUNICATE, 0)) { rt_printf("Error task create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_task_create(&tconnect, NULL, 0, PRIORITY_TCONNECT, 0)) { rt_printf("Error task create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_task_create(&tmove, NULL, 0, PRIORITY_TMOVE, 0)) { rt_printf("Error task create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_task_create(&tsend, NULL, 0, PRIORITY_TSEND, 0)) { rt_printf("Error task create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_task_create(&twatchdog, NULL, 0, PRIORITY_TWATCHDOG, 0)) { rt_printf("Error task create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_task_create(&tbattery, NULL, 0, PRIORITY_TBATTERY, 0)) { rt_printf("Error task create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_task_create(&tcam, NULL, 0, PRIORITY_TCAM, 0)) { rt_printf("Error task create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_task_create(&tposition, NULL, 0, PRIORITY_TPOSITION, 0)) { rt_printf("Error task create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_task_create(&tarena, NULL, 0, PRIORITY_TARENA, 0)) { rt_printf("Error task create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_task_create(&tmission, NULL, 0, PRIORITY_TMISSION, 0)) { rt_printf("Error task create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } /* Definition des periodes */ rt_task_set_periodic(&tmove, TM_NOW, 200000000); // 200ms rt_task_set_periodic(&tsend, TM_NOW, 200000000); // 200ms rt_task_set_periodic(&twatchdog, TM_NOW, 1000000000); // 1s rt_task_set_periodic(&tbattery, TM_NOW, 250000000); // 250ms rt_task_set_periodic(&tcam, TM_NOW, 600000000); // 600ms rt_task_set_periodic(&tposition, TM_NOW, 600000000); // 600ms rt_task_set_periodic(&tmission, TM_NOW, 600000000); // 600ms /* Creation des files de messages */ if (err = rt_queue_create(&queueMsgGUI, "toto", MSG_QUEUE_SIZE*sizeof(DMessage), MSG_QUEUE_SIZE, Q_FIFO)) { rt_printf("Error msg queue create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } /* Creation des structures globales du projet */ areneValidee = 1; arena = 0; robot = d_new_robot(); mvt = d_new_movement(); server = d_new_server(); image = d_new_image(); positionRobot = d_new_position(); positionVoulue = d_new_position(); etat_communication = malloc(sizeof(Etat_communication_t)); etat_communication->robot = 1; etat_communication->moniteur = 1; }
void initStruct(void) { int err; /* Creation des mutex */ if (err = rt_mutex_create(&mutexEtat, NULL)) { rt_printf("Error mutex create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_mutex_create(&mutexMove, NULL)) { rt_printf("Error mutex create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_mutex_create(&mutexRobot, NULL)) { rt_printf("Error mutex create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_mutex_create(&mutexArena, NULL)) { rt_printf("Error mutex create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_mutex_create(&mutexPosition, NULL)) { rt_printf("Error mutex create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_mutex_create(&mutexImage, NULL)) { rt_printf("Error mutex create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_mutex_create(&mutexMission, NULL)) { rt_printf("Error mutex create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } /* Creation du semaphore */ if (err = rt_sem_create(&semConnecterRobot, NULL, 0, S_FIFO)) { rt_printf("Error semaphore create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_sem_create(&semGetImage, NULL, 0, S_FIFO)) { rt_printf("Error semaphore create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_sem_create(&semDetectArena, NULL, 0, S_FIFO)) { rt_printf("Error semaphore create: %s\n", strerror(-err)); } if (err = rt_sem_create(&semComputePosition, NULL, 0, S_FIFO)) { rt_printf("Error semaphore create: %s\n", strerror(-err)); } if (err = rt_sem_create(&semwatchDog, NULL, 0, S_FIFO)) { rt_printf("Error semaphore create: %s\n", strerror(-err)); } if (err = rt_sem_create(&semCommunicate, NULL, 0, S_FIFO)) { rt_printf("Error semaphore create: %s\n", strerror(-err)); } if (err = rt_sem_create(&semConnect, NULL, 0, S_FIFO)) { rt_printf("Error semaphore create: %s\n", strerror(-err)); } /* Creation des taches */ if (err = rt_task_create(&tServeur, NULL, 0, PRIORITY_TSERVEUR, 0)) { rt_printf("Error task create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_task_create(&tconnect, NULL, 0, PRIORITY_TCONNECT, 0)) { rt_printf("Error task create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_task_create(&tmove, NULL, 0, PRIORITY_TMOVE, 0)) { rt_printf("Error task create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_task_create(&tenvoyer, NULL, 0, PRIORITY_TENVOYER, 0)) { rt_printf("Error task create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_task_create(&tbattery, NULL, 0, PRIORITY_TBATTERY, 0)) { rt_printf("Error task create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_task_create(&tcamera, NULL, 0, PRIORITY_TCAMERA, 0)) { rt_printf("Error task create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_task_create(&tverify, NULL, 0, PRIORITY_TVERIFY, 0)) { rt_printf("Error task create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_task_create(&tcomputepos, NULL, 0, PRIORITY_TCOMPUTEPOS, 0)) { rt_printf("Error task create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } if (err = rt_task_create(&tarena, NULL, 0, PRIORITY_TARENA, 0)) { rt_printf("Error task create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } /* Creation des files de messages */ if (err = rt_queue_create(&queueMsgGUI, "toto", MSG_QUEUE_SIZE * sizeof (DMessage), MSG_QUEUE_SIZE, Q_FIFO)) { rt_printf("Error msg queue create: %s\n", strerror(-err)); exit(EXIT_FAILURE); } /* Creation des structures globales du projet */ robot = d_new_robot(); move = d_new_movement(); serveur = d_new_server(); camera = d_new_camera(); battery = d_new_battery(); mission = NULL; position = NULL; arena = NULL; image = NULL; }