APP 4
Dependencies: mbed CRC16 mbed-rtos
Revision 27:011ad1667040, committed 2016-02-23
- Comitter:
- manl2003
- Date:
- Tue Feb 23 21:15:05 2016 +0000
- Parent:
- 26:f2b37f9dfca9
- Commit message:
- Tout beau, mef inclue.
Changed in this revision
MEF.cpp | Show annotated file Show diff for this revision Revisions of this file |
MEF.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r f2b37f9dfca9 -r 011ad1667040 MEF.cpp --- a/MEF.cpp Tue Feb 23 20:56:47 2016 +0000 +++ b/MEF.cpp Tue Feb 23 21:15:05 2016 +0000 @@ -21,6 +21,7 @@ case PREAMBLE : default : { + //On vérifie si dans les 8 derniers bits se trouve le préambule m_InputBuffer[0] = m_InputBuffer[1]; m_InputBuffer[1] = m_InputBuffer[2]; m_InputBuffer[2] = m_InputBuffer[3]; @@ -38,6 +39,7 @@ }break; case START : { + //Verification du start byte m_InputBuffer[m_Counter] = bit; m_Counter++; if(m_Counter >= 8) @@ -49,7 +51,7 @@ } else { - //Bluboom + //Frame drop _decodeError(); state = PREAMBLE; init(); @@ -58,6 +60,7 @@ }break; case TYPE : { + //8 bits de type m_Counter ++; if(m_Counter >= 8) { @@ -68,6 +71,7 @@ }break; case LENGTH : { + //Longueur du data m_InputBuffer[m_Counter] = bit; m_Counter++; if(m_Counter >= 8) @@ -80,6 +84,7 @@ }break; case DATA : { + //Interprétation du data m_BSPayload[m_Counter] = bit; if (((m_Counter + 1) % 8) == 0 && m_Counter != 0) { @@ -95,13 +100,14 @@ }break; case CRC16STATE : { + //Réception du checksum et calcul m_InputBuffer[m_Counter] = bit; m_Counter++; if(m_Counter >= 16) { if(!compareCRC()) { - //BOOMBOOM + //Frame drop _decodeError(); state = PREAMBLE; init(); @@ -116,6 +122,7 @@ }break; case END : { + //Calcul du byte de fin m_InputBuffer[m_Counter] = bit; m_Counter++; if(m_Counter >= 8) @@ -124,12 +131,11 @@ { state = PREAMBLE; m_Counter = 0; - //CALLBACK + //Message complet, appel du callback _decodeCallback(m_BSPayload, m_DataSize); } else { - //BOOMBOOM _decodeError(); state = PREAMBLE; init(); @@ -138,6 +144,7 @@ }break; } + //Callback pour avertir le main d'un changement d'état _updateState(state); } @@ -196,7 +203,3 @@ return m_CRC == incommingCRC; } -void MEF::error() -{ - -} \ No newline at end of file
diff -r f2b37f9dfca9 -r 011ad1667040 MEF.h --- a/MEF.h Tue Feb 23 20:56:47 2016 +0000 +++ b/MEF.h Tue Feb 23 21:15:05 2016 +0000 @@ -13,17 +13,22 @@ private: + //Verification du start byte bool startChecker(); + //Verification du preamble byte bool preambleChecker(); + //Calcul de la longueur int calculateSize(); bool compareCRC(); - void error(); void init(); - + //État actuel de la mef STATES state; + //Buffer d'entrée bitset<16> m_InputBuffer; + //Payload en bits bitset<MAX_DATA> m_BSPayload; + //Payload en char char m_CPayload[80]; int m_Counter; int m_DataSize;