ajout module_mouvement

Dependencies:   mbed xbee_lib ADXL345_I2C IMUfilter ITG3200 Motor RangeFinder Servo mbos PID

Fork of Labo_TRSE_Drone by HERBERT Nicolas

Files at this revision

API Documentation at this revision

Comitter:
IngesupMbed01
Date:
Wed Apr 17 13:53:25 2013 +0000
Parent:
31:a0800d3da787
Child:
33:ec7d635636bf
Commit message:
Module Communication modifi?.

Changed in this revision

Module_Communication/Module_Communication.cpp Show annotated file Show diff for this revision Revisions of this file
Service/Buffer_Trame.h Show annotated file Show diff for this revision Revisions of this file
--- a/Module_Communication/Module_Communication.cpp	Wed Apr 17 10:16:19 2013 +0000
+++ b/Module_Communication/Module_Communication.cpp	Wed Apr 17 13:53:25 2013 +0000
@@ -30,8 +30,8 @@
     m_xbee = new xbee(p9, p10, p11);
     m_trameRxBuffer = C_FrameBuffer();
     m_trameTxBuffer = C_FrameBuffer();
-    m_charRxBuffer = new char[9];
-    m_charTxBuffer = new char[9];
+    m_charRxBuffer = new char[17];
+    m_charTxBuffer = new char[17];
  }
  
  /* DESTRUCTEUR */
@@ -52,17 +52,18 @@
  
  void C_ModuleCommunication::envoiDeTrame(void)
  {
-    m_xbee->SendData(m_charTxBuffer);
-    /*
-    frame newFrame = m_trameTxBuffer->frameBuffer();
-    m_charTxBuffer[0] = newFrame.identifier;
+    frame newFrame = m_trameTxBuffer.frameBuffer();
+    m_charTxBuffer[0] = 0x02;
+    m_charTxBuffer[1] = newFrame.systemIdentifier;
+    m_charTxBuffer[2] = newFrame.moduleIdentifier;
+    m_charTxBuffer[3] = newFrame.messageIdentifier;
+    m_charTxBuffer[16] = 0x03;
     
-    for(int i = 0; i < 8; i++) {
-        m_charTxBuffer[i+1] = newFrame.data[i];
+    for(int i = 0; i < 12; i++) {
+        m_charTxBuffer[i+4] = newFrame.data[i];
     }
     
     m_xbee->SendData(m_charTxBuffer);
-    */
  }
  
  void C_ModuleCommunication::receptionDeTrame(void)
@@ -70,16 +71,18 @@
     Serial pc(USBTX, USBRX);
     m_xbee->RecieveData(m_charRxBuffer, 0);
     pc.printf("You said:%s \n",m_charRxBuffer);
-    /*
+    
+    
     frame newFrame;
-    newFrame.identifier = m_charRxBuffer[0];
+    newFrame.systemIdentifier = m_charRxBuffer[1];
+    newFrame.moduleIdentifier = m_charRxBuffer[2];
+    newFrame.messageIdentifier = m_charRxBuffer[3];
     
-    for(int i = 0; i < 8; i++) {
-        newFrame.data[i] = m_charRxBuffer[i+1];
+    for(int i = 0; i < 12; i++) {
+        newFrame.data[i] = m_charRxBuffer[i+4];
     }
     
-    m_trameRxBuffer->frameBuffer(newFrame);
-    */
+    m_trameRxBuffer.frameBuffer(newFrame);
  }
  
  void C_ModuleCommunication::traitementTrame(void)
@@ -88,8 +91,8 @@
     
     frame newFrame = m_trameRxBuffer.frameBuffer();
     
-    switch(newFrame.identifier) {
-        case 0x31 :
+    switch(newFrame.moduleIdentifier) {
+        case 0x31 : 
                     break;
         case 0x32 : 
                     break;
--- a/Service/Buffer_Trame.h	Wed Apr 17 10:16:19 2013 +0000
+++ b/Service/Buffer_Trame.h	Wed Apr 17 13:53:25 2013 +0000
@@ -26,8 +26,10 @@
  #define default_size 50
  
  typedef struct {
-    char identifier;
-    char data [8];
+    char systemIdentifier;
+    char moduleIdentifier;
+    char messageIdentifier;
+    char data [12];
  }frame;
  
  class C_FrameBuffer {