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 03 12:16:14 2013 +0000
Parent:
23:7f5681d8d5b5
Child:
25:b447351dcbc7
Child:
26:814d9b08aa68
Commit message:
Ajout de m?thodes pour le Module Communication

Changed in this revision

Module_Communication/Module_Communication.cpp Show annotated file Show diff for this revision Revisions of this file
Module_Communication/Module_Communication.h Show annotated file Show diff for this revision Revisions of this file
Service/Buffer_Trame.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Module_Communication/Module_Communication.cpp	Wed Apr 03 10:36:21 2013 +0000
+++ b/Module_Communication/Module_Communication.cpp	Wed Apr 03 12:16:14 2013 +0000
@@ -28,20 +28,56 @@
  C_ModuleCommunication::C_ModuleCommunication()
  {
     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];
  }
  
  /* DESTRUCTEUR */
  C_ModuleCommunication::~C_ModuleCommunication()
  {
- 
+    delete [] m_charRxBuffer;
+    delete [] m_charTxBuffer;
+    delete m_xbee;
  }
  
  /* Point d'entrée de la tache Module Video */
- void C_ModuleCommunication::receptionDeTrame(void)
+ void C_ModuleCommunication::moduleCommunicationTask(void)
  {
     while(1){
     // Code
     }
  }
  
- 
\ No newline at end of file
+ void C_ModuleCommunication::envoiDeTrame(void)
+ {
+    pc.scanf("%s",m_charTxBuffer); //Read data from serial console
+    m_xbee->SendData(m_charTxBuffer);
+    /*
+    frame newFrame = m_trameTxBuffer->frameBuffer();
+    m_charTxBuffer[0] = newFrame.identifier;
+    
+    for(int i = 0; i < 8; i++) {
+        m_charTxBuffer[i+1] = newFrame.data[i];
+    }
+    
+    m_xbee->SendData(m_charTxBuffer);
+    */
+ }
+ 
+ void C_ModuleCommunication::receptionDeTrame(void)
+ {
+    m_xbee->RecieveData(m_charRxBuffer, 0);
+    pc.printf("You said:%s",m_charRxBuffer);
+    /*
+    frame newFrame;
+    newFrame.identifier = m_charRxBuffer[0];
+    
+    for(int i = 0; i < 8; i++) {
+        newFrame.data[0] = m_charRxBuffer[i+1];
+    }
+    
+    m_trameRxBuffer->frameBuffer(newFrame);
+    */
+ }
\ No newline at end of file
--- a/Module_Communication/Module_Communication.h	Wed Apr 03 10:36:21 2013 +0000
+++ b/Module_Communication/Module_Communication.h	Wed Apr 03 12:16:14 2013 +0000
@@ -23,13 +23,19 @@
  
  #include "mbos.h"
  #include "xbee.h"
+ #include "Buffer_Trame.h"
+ 
+ Serial pc(USBTX, USBRX); //Initalise PC serial comms
  
  class C_ModuleCommunication
  {
  private :
     /* ATTRIBUTS */
     xbee * m_xbee;
-    
+    C_FrameBuffer m_trameRxBuffer;
+    C_FrameBuffer m_trameTxBuffer;
+    char * m_charRxBuffer;
+    char * m_charTxBuffer;
  
  public :
     /* CONSTRUCTEUR(S) */
--- a/Service/Buffer_Trame.cpp	Wed Apr 03 10:36:21 2013 +0000
+++ b/Service/Buffer_Trame.cpp	Wed Apr 03 12:16:14 2013 +0000
@@ -22,7 +22,7 @@
  /* CONSRTRUCTEUR(S) */
  C_FrameBuffer::C_FrameBuffer()
  {
-    m_frameBuffer = new frame [default_size];
+    m_frameBuffer = new frame[default_size];
     m_maxSize = default_size;
     m_currentReadIndex = 0;
     m_currentWriteIndex = 0;
@@ -31,7 +31,7 @@
  C_FrameBuffer::C_FrameBuffer(unsigned int size)
  {
     m_maxSize = size;
-    m_frameBuffer = new frame [m_maxSize];
+    m_frameBuffer = new frame[m_maxSize];
     m_currentReadIndex = 0;
     m_currentWriteIndex = 0;
  }