Projet Drone de surveillance du labo TRSE (INGESUP)

Dependencies:   mbed PID ADXL345 Camera_LS_Y201 ITG3200 RangeFinder mbos xbee_lib Motor Servo

Revision:
30:119e060b45b3
Parent:
29:a0800d3da787
Child:
31:ec7d635636bf
--- 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;