[fix] request switch management (plane thread let ctrlTerm use common socket)
This commit is contained in:
parent
061893b35d
commit
a31c97942b
|
@ -79,7 +79,7 @@ void* managePlane(void* THREADABLE_ARGS){
|
|||
}
|
||||
|
||||
/* 3. Si pas pour nous -> on attends puis on reboucle */
|
||||
if( buffer[0] != 0x55 ){ // '01010101'(2) '55'(16)
|
||||
if( buffer[0] == 0x55 ){ // '01010101'(2) '55'(16)
|
||||
if( DEBUGMOD&BUF ) printf("{tcp_com}(%d) Let request to update routine\n", index);
|
||||
sleep(0.5);
|
||||
continue;
|
||||
|
@ -88,7 +88,7 @@ void* managePlane(void* THREADABLE_ARGS){
|
|||
/* (2) Données
|
||||
---------------------------------------------------------*/
|
||||
/* 1. On lit sur la socket */
|
||||
read = recv(SOCKET, buffer, MAX_BUF_LEN, 0);
|
||||
read = recv(SOCKET, buffer+1, MAX_BUF_LEN-1, 0);
|
||||
|
||||
/* 2.1. Si erreur reception (-1:erreur, 0:fermeture client propre) */
|
||||
if( read <= 0 ){
|
||||
|
@ -97,8 +97,8 @@ void* managePlane(void* THREADABLE_ARGS){
|
|||
}
|
||||
|
||||
/* 2.2. Si message trop court */
|
||||
if( read != PLANE_LEN ){
|
||||
if( DEBUGMOD&BUF ) printf("{tcp_com}(%d) read: %d (expected: %d)\n", index, read, (int) PLANE_LEN);
|
||||
if( read != PLANE_LEN-1 ){
|
||||
if( DEBUGMOD&BUF ) printf("{tcp_com}(%d) read: %d (expected: %d)\n", index, read+1, (int) PLANE_LEN);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -418,7 +418,7 @@ void* manageCtrlTerm(void* THREADABLE_ARGS){
|
|||
|
||||
/* 3. Si on a pas trouvé -> on quitte l'udpdate */
|
||||
if( pindex <= -1 || arg->sgca->socket[pindex] <= -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);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -142,15 +142,14 @@ void send_data(){
|
|||
request.spd = htonl( ctrl.speed );
|
||||
|
||||
/* 3. Copie buffer */
|
||||
buffer[0] = 0x55;
|
||||
memcpy(buffer+sizeof(char)*1+sizeof(int)*0, &request.code, sizeof(char)*6 );
|
||||
memcpy(buffer+sizeof(char)*7+sizeof(int)*0, &request.x, sizeof(int) );
|
||||
memcpy(buffer+sizeof(char)*7+sizeof(int)*1, &request.y, sizeof(int) );
|
||||
memcpy(buffer+sizeof(char)*7+sizeof(int)*2, &request.z, sizeof(int) );
|
||||
memcpy(buffer+sizeof(char)*7+sizeof(int)*3, &request.cap, sizeof(int) );
|
||||
memcpy(buffer+sizeof(char)*7+sizeof(int)*4, &request.spd, sizeof(int) );
|
||||
memcpy(buffer+sizeof(char)*0+sizeof(int)*0, &request.code, sizeof(char)*6 );
|
||||
memcpy(buffer+sizeof(char)*6+sizeof(int)*0, &request.x, sizeof(int) );
|
||||
memcpy(buffer+sizeof(char)*6+sizeof(int)*1, &request.y, sizeof(int) );
|
||||
memcpy(buffer+sizeof(char)*6+sizeof(int)*2, &request.z, sizeof(int) );
|
||||
memcpy(buffer+sizeof(char)*6+sizeof(int)*3, &request.cap, sizeof(int) );
|
||||
memcpy(buffer+sizeof(char)*6+sizeof(int)*4, &request.spd, sizeof(int) );
|
||||
|
||||
read = send(commu_socket, buffer, PLANE_DATA_LEN/sizeof(char) + 1, 0);
|
||||
read = send(commu_socket, buffer, PLANE_DATA_LEN/sizeof(char), 0);
|
||||
|
||||
if( read <= 0 ){
|
||||
printf("Cannot send\n");
|
||||
|
@ -338,7 +337,7 @@ void update(){
|
|||
/* [3] Gestion de la réponse
|
||||
=========================================================*/
|
||||
/* 1. On prépare la réponse */
|
||||
buffer[0] = 0;
|
||||
buffer[0] = 0x55;
|
||||
buffer[1] = request.flags;
|
||||
printf("Response flags : %d\n", request.flags);
|
||||
|
||||
|
|
Loading…
Reference in New Issue