ajout module_mouvement

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

Fork of Labo_TRSE_Drone by HERBERT Nicolas

Module_Communication/Module_Communication.cpp

Committer:
IngesupMbed01
Date:
2013-04-03
Revision:
28:8b5ccd2f837e
Parent:
24:3462a304f9a0
Child:
31:a0800d3da787

File content as of revision 28:8b5ccd2f837e:

 /* Copyright (c) 2012 - 2013 AUTHEUR
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED 
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
 /*
 * Description : Cette classe contient les fonctionnalités du module communication.
                 Le module communication gère la communication entre les modules présents sur le drône et le PC.
 * Input
 * Output
 */
 
 #include "Module_Communication.h"
 
 // Pointeur sur la classe systeme d'exploitation instancié dans le main
 extern mbos *os;
 
 
 /* CONSRTRUCTEUR(S) */
 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::moduleCommunicationTask(void)
 {
    while(1){
    // Code
    }
 }
 
 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);
    */
 }
 
 void C_ModuleCommunication::traitementTrame(void)
 {
    if(m_trameRxBuffer.numberMessage() <= 0) return;
    
    frame newFrame = m_trameRxBuffer.frameBuffer();
    
    switch(newFrame.identifier) {
        case 0x31 :
                    break;
        case 0x32 : 
                    break;
                    
    }
 }