Replaced term_req 0x10 with TERMREQ_OFF flag constant

This commit is contained in:
xdrm-brackets 2017-05-05 13:51:07 +02:00
parent 6848840638
commit 265feabb59
4 changed files with 11 additions and 9 deletions

View File

@ -17,6 +17,7 @@
#define TERMREQ_CAP 0x02 #define TERMREQ_CAP 0x02
#define TERMREQ_SPD 0x04 #define TERMREQ_SPD 0x04
#define TERMREQ_ALT 0x08 #define TERMREQ_ALT 0x08
#define TERMREQ_OFF 0x10
#define PLANE_LEN ( sizeof(char)*6+sizeof(int)*5 ) #define PLANE_LEN ( sizeof(char)*6+sizeof(int)*5 )
struct plane{ struct plane{

View File

@ -137,7 +137,7 @@ void* managePlane(void* THREADABLE_ARGS){
} }
/* 4. On copie/met à jour les valeurs */ /* 4. On copie/met à jour les valeurs */
if( tmpFlags != 0x10 ){ // gestion réponse ctrlTerm if( tmpFlags != TERMREQ_OFF ){ // gestion réponse ctrlTerm
arg->sgca->unit[pindex].flags = tmpFlags; // on met à jour les flags arg->sgca->unit[pindex].flags = tmpFlags; // on met à jour les flags
while( arg->sgca->unit[pindex].thrId == 0xf0 ); // on attend le numéro de thread while( arg->sgca->unit[pindex].thrId == 0xf0 ); // on attend le numéro de thread
printf("{tcp_com}(%d) Waking up UDP threaad@%d for ctrlTerm response\n", index, arg->sgca->unit[pindex].thrId); printf("{tcp_com}(%d) Waking up UDP threaad@%d for ctrlTerm response\n", index, arg->sgca->unit[pindex].thrId);
@ -264,7 +264,7 @@ void* manageViewTerm(void* THREADABLE_ARGS){
sent = recvfrom(arg->socket, buffer, 1, 0, (struct sockaddr*) &clientInfo, &len); sent = recvfrom(arg->socket, buffer, 1, 0, (struct sockaddr*) &clientInfo, &len);
/* 2. Gestion erreur (erreur ou mauvais feedback != 0x10) */ /* 2. Gestion erreur (erreur ou mauvais feedback != 0x10) */
if( sent <= 0 || buffer[0] != 0x10 ){ if( sent <= 0 || buffer[0] != TERMREQ_OFF ){
printf("{udp_vterm}{com}(%d) Unable to recv feedback -> exiting\n", index); printf("{udp_vterm}{com}(%d) Unable to recv feedback -> exiting\n", index);
break; break;
} }
@ -420,7 +420,7 @@ void* manageCtrlTerm(void* THREADABLE_ARGS){
/* 3. Si on a pas trouvé -> on quitte l'udpdate */ /* 3. Si on a pas trouvé -> on quitte l'udpdate */
if( pindex <= -1 || arg->sgca->unit[pindex].socket <= -1 ){ if( pindex <= -1 || arg->sgca->unit[pindex].socket <= -1 ){
printf("{udp_cterm}{com}(%d) Plane unknown or unreachable, passing\n", index); printf("{udp_cterm}{com}(%d) Plane unknown or unreachable, passing\n", index);
request.flags = 0x10; request.flags = TERMREQ_OFF;
break; break;
} }
@ -439,7 +439,7 @@ void* manageCtrlTerm(void* THREADABLE_ARGS){
/* 3. On envoie la requête à l'avion */ /* 3. On envoie la requête à l'avion */
if( send(arg->sgca->unit[pindex].socket, buffer, count/sizeof(char), 0) <= 0 ){ if( send(arg->sgca->unit[pindex].socket, buffer, count/sizeof(char), 0) <= 0 ){
printf("{udp_cterm}{com}(%d) Cannot send request to plane\n", index); printf("{udp_cterm}{com}(%d) Cannot send request to plane\n", index);
request.flags = 0x10; request.flags = TERMREQ_OFF;
break; break;
} }
@ -450,11 +450,11 @@ void* manageCtrlTerm(void* THREADABLE_ARGS){
arg->sgca->unit[pindex].thrId = index; arg->sgca->unit[pindex].thrId = index;
sleep(2); sleep(2);
flags = arg->sgca->unit[pindex].flags; // on récupère les flags flags = arg->sgca->unit[pindex].flags; // on récupère les flags
arg->sgca->unit[pindex].flags = 0x10; // on reset les flags arg->sgca->unit[pindex].flags = TERMREQ_OFF; // on reset les flags
if( flags == 0x10 ){ if( flags == TERMREQ_OFF ){
printf("{udp_cterm}{com}(%d) Cannot get response from plane %d bytes (%d expected)\n", index, count, (int) PLANE_LEN); printf("{udp_cterm}{com}(%d) Cannot get response from plane %d bytes (%d expected)\n", index, count, (int) PLANE_LEN);
request.flags = 0x10; request.flags = TERMREQ_OFF;
break; break;
} }

View File

@ -304,13 +304,13 @@ void update(){
int received; int received;
struct sgca_req request; struct sgca_req request;
char buffer[MAX_BUF_LEN] = {0}; char buffer[MAX_BUF_LEN] = {0};
char persistentFlags = 0x10; char persistentFlags = REQ_OFF;
while( 1 ){ while( 1 ){
calc_ctrl(); calc_ctrl();
send_data(persistentFlags); send_data(persistentFlags);
persistentFlags = 0x10; persistentFlags = REQ_OFF;
/* [1] Gestion réception avec timeout /* [1] Gestion réception avec timeout
=========================================================*/ =========================================================*/

View File

@ -53,6 +53,7 @@
#define REQ_CAP 0x02 #define REQ_CAP 0x02
#define REQ_SPD 0x04 #define REQ_SPD 0x04
#define REQ_ALT 0x08 #define REQ_ALT 0x08
#define REQ_OFF 0x10
struct sgca_req{ struct sgca_req{
char flags; char flags;