test des capteurs/actionneurs petit robot

Fork of mbed_tes_cpt by CRAC Team

Revision:
5:7e1c328c5d50
Parent:
3:43843ab8af47
--- a/CAN.cpp	Sun May 21 16:10:38 2017 +0000
+++ b/CAN.cpp	Thu May 25 06:35:22 2017 +0000
@@ -52,6 +52,45 @@
     if(FIFO_occupation!=0) {
         
         switch(msgRxBuffer[FIFO_lecture].id) {
+            #ifdef ARRIERE
+            case ACKNOWLEDGE_GLOBAL_JACK:
+                jack.fall(NULL);
+                EnvoieJack=0;
+                TimeJack.stop();
+                break; 
+            #endif
+            #ifdef AVANT
+            case CHECK_CARTE_AVANT:
+                EtatCarteAvant = 1;
+                Cote = 1; //Avant
+                //ACK de reception des actions a effectuer
+                msgTx.id = 0x73;
+                msgTx.len = 0;
+                can.write(msgTx);
+                wait_us(50);
+                break;
+            #endif
+                
+            #ifdef ARRIERE    
+            case CHECK_CARTE_ARRIERE:
+                EtatCarteArriere = 1;
+                Cote = 2; //Arriere
+                //ACK de reception des actions a effectuer
+                msgTx.id = 0x74;
+                msgTx.len = 0;
+                can.write(msgTx);
+                wait_us(50);
+                break;
+            #endif
+            
+            case GLOBAL_GAME_END:
+                EtatGameEnd = 1;  
+                break;
+            
+            case GLOBAL_FUNNY_ACTION:
+                EtatFunnyAction  = msgRxBuffer[FIFO_lecture].data[0];
+                Cote = msgRxBuffer[FIFO_lecture].data[1];
+                break;
             
             case ELECTROVANNE:
                 EtatElectroVanne  = msgRxBuffer[FIFO_lecture].data[0];
@@ -62,11 +101,22 @@
                 ActionPompe = 1;
                 EtatPompe  = msgRxBuffer[FIFO_lecture].data[0];
                 Cote = msgRxBuffer[FIFO_lecture].data[1];
+                
+                msgTx.id = ACKNOWLEDGE_POMPES;
+                msgTx.len = 1;
+                msgTx.data[0] = POMPE_PWM;
+                can.write(msgTx);
+                wait_us(50);
                 break;
                 
             case TURBINE:
                 EtatTurbine = msgRxBuffer[FIFO_lecture].data[0];
                 Cote = msgRxBuffer[FIFO_lecture].data[1];
+                
+                msgTx.id = SERVO_AX12_ACK;
+                msgTx.len = 1;
+                msgTx.data[0] = msgRxBuffer[FIFO_lecture].data[0];
+                can.write(msgTx);
                 break;
                 
             case LANCEUR:
@@ -97,6 +147,7 @@
                 GetPositionAx12();
                 break;
             
+            
         }
         action_a_effectuer=1;
         FIFO_lecture=(FIFO_lecture+1)%SIZE_FIFO;