APP4

Dependencies:   mbed-rtos mbed

Fork of rtos_basic by mbed official

Files at this revision

API Documentation at this revision

Comitter:
jpbaillargeon
Date:
Tue Oct 23 18:21:59 2018 +0000
Parent:
21:846e642eb63e
Child:
23:c704dd99d3f1
Commit message:
final

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Oct 23 18:08:32 2018 +0000
+++ b/main.cpp	Tue Oct 23 18:21:59 2018 +0000
@@ -25,7 +25,7 @@
 Mail<message_t,128> mail_box;
 Timer timer;
 int etat;
-const int longMessage = 65;
+const int longMessage = 128;
 bool messageUtile[longMessage] = {0,0,1,0,1,1,1,0,
                         1,0,1,0,0,0,0,0,
                         0,0,1,1,1,0,1,0,
@@ -33,7 +33,15 @@
                         0,1,0,1,1,0,1,1,
                         1,0,1,0,1,1,1,0,
                         0,0,1,0,1,0,0,0,
-                        1,1,0,1,0,1,1,0,0};
+                        1,1,0,1,0,1,1,0,
+                        0,0,1,0,1,1,1,0,
+                        1,0,1,0,0,0,0,0,
+                        0,0,1,1,1,0,1,0,
+                        1,1,0,0,0,1,1,0,
+                        0,1,0,1,1,0,1,1,
+                        1,0,1,0,1,1,1,0,
+                        0,0,1,0,1,0,0,0,
+                        1,1,0,1,0,1,1,0};
 
 //CRC16 (détection des erreurs) ----------------------------------------------------------------------------------------------------
 unsigned short crc16(bool* data_p, int length){
@@ -386,7 +394,7 @@
     led1 = !led1;
     message_t *a = mail_box.alloc();
     a->time = timer.read_ms();;
-    a->front = 0;
+    a->front = 0; //Si rise, il s'agit d'un 0 en Manchester
     mail_box.put(a);
 }
 
@@ -394,47 +402,53 @@
     led2 = !led2;
     message_t *a = mail_box.alloc();
     a->time = timer.read_ms();;
-    a->front = 1;
+    a->front = 1; //Si fall, il s'agit d'un 1 en Manchester
     mail_box.put(a);
 }
  
 
 int main() {
-       printf("\r\n\r\n**********Debut**********\r\n");
-       int length = sizeof(messageUtile);
-       bool message[length+6*8];
-       bool manchester[(length+6*8)*2];
-       creationTrame(message,length);
-       printf("\r\nMessage : \r\n");
-       for(int i=0; i<sizeof(message); i++){
-           if(i>0 && i%8 == 0){
-               printf(" ");
-           }
-           printf("%d",message[i]);
+    printf("\r\n\r\n**********Debut**********\r\n");
+    int length = sizeof(messageUtile);
+    bool message[length+6*8]; //Taille total du message avec les entêtes
+    bool manchester[(length+6*8)*2];
+    creationTrame(message,length);
+    
+    //Afficher les bits envoyés
+    printf("\r\nMessage : \r\n");
+    for(int i=0; i<sizeof(message); i++){
+       if(i>0 && i%8 == 0){
+           printf(" ");
        }
-       printf("\r\n");
-       convertMessageToManchester(manchester, message, length+6*8);
-       printf("\r\nMessage Manchester: \r\n");
-       for(int i=0; i<sizeof(manchester); i++){
-           if(i>0 && i%16 == 0){
-               printf("\r\n");
-           }
-           if(i>0 && i%2 == 0){
-               printf(" ");
-           }
-           printf("%d",manchester[i]);
+       printf("%d",message[i]);
+    }
+    printf("\r\n");
+    
+    convertMessageToManchester(manchester, message, length+6*8);
+    
+    //Affiche les bits en manchester
+    printf("\r\nMessage Manchester: \r\n");
+    for(int i=0; i<sizeof(manchester); i++){
+       if(i>0 && i%16 == 0){
+           printf("\r\n");
+       }
+       if(i>0 && i%2 == 0){
+           printf(" ");
        }
-       printf("\r\n");
-       
-       
-       
-       envoi_t.start(envoiTrame);
-       reception_t.start(receptionTrames);
-        button.rise(&rise);  // attach the address of the flip function to the rising edge
-        button.fall(&fall);
-        while(1) {           // wait around, interrupts will interrupt this!
-            flash = !flash;
-            wait(0.25);
-        }
+       printf("%d",manchester[i]);
+    }
+    printf("\r\n");
+    
+    //Démarrage des threads
+    envoi_t.start(envoiTrame);
+    reception_t.start(receptionTrames);
+    
+    button.rise(&rise);  // attach the address of the flip function to the rising edge
+    button.fall(&fall);
+    while(1) {           // wait around, interrupts will interrupt this!
+        flash = !flash;
+        wait(0.25);
+        //Permet d'indiquer si l'application tourne
+    }
 }
  
\ No newline at end of file