Polytech school project. RICM4 students, see http://air.imag.fr/index.php/Projets-2016-2017-Station_de_pompage_connect%C3%A9e for more information
Fork of SX1276PingPong by
ordre.cpp@16:1643ac8ba29f, 2017-04-01 (annotated)
- Committer:
- chevamax
- Date:
- Sat Apr 01 12:14:27 2017 +0000
- Revision:
- 16:1643ac8ba29f
Version finale
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chevamax | 16:1643ac8ba29f | 1 | #include "mbed.h" |
chevamax | 16:1643ac8ba29f | 2 | #include "ordre.h" |
chevamax | 16:1643ac8ba29f | 3 | #include "debug.h" |
chevamax | 16:1643ac8ba29f | 4 | |
chevamax | 16:1643ac8ba29f | 5 | Ordre::Ordre(char id, char idR, char niveau){ |
chevamax | 16:1643ac8ba29f | 6 | //TODO |
chevamax | 16:1643ac8ba29f | 7 | } |
chevamax | 16:1643ac8ba29f | 8 | |
chevamax | 16:1643ac8ba29f | 9 | char getiemebit1(char c, int i) |
chevamax | 16:1643ac8ba29f | 10 | { |
chevamax | 16:1643ac8ba29f | 11 | return ((c>>(7-i)) & 1); |
chevamax | 16:1643ac8ba29f | 12 | } |
chevamax | 16:1643ac8ba29f | 13 | |
chevamax | 16:1643ac8ba29f | 14 | Ordre::Ordre(char* trameRecu){ |
chevamax | 16:1643ac8ba29f | 15 | idEmetteur = trameRecu[1]; |
chevamax | 16:1643ac8ba29f | 16 | idRecepteur = trameRecu[0]; |
chevamax | 16:1643ac8ba29f | 17 | niveauCuve = trameRecu[2]>>3; |
chevamax | 16:1643ac8ba29f | 18 | ordreAFaire = (trameRecu[2]&0x4)>>2; |
chevamax | 16:1643ac8ba29f | 19 | |
chevamax | 16:1643ac8ba29f | 20 | /*debug("idEmetteur = "); |
chevamax | 16:1643ac8ba29f | 21 | for(int i=0; i < 8; i++){ |
chevamax | 16:1643ac8ba29f | 22 | if(getiemebit1(trameRecu[1], i)){ |
chevamax | 16:1643ac8ba29f | 23 | debug("1"); |
chevamax | 16:1643ac8ba29f | 24 | } |
chevamax | 16:1643ac8ba29f | 25 | else{ |
chevamax | 16:1643ac8ba29f | 26 | debug("0"); |
chevamax | 16:1643ac8ba29f | 27 | } |
chevamax | 16:1643ac8ba29f | 28 | } |
chevamax | 16:1643ac8ba29f | 29 | debug("\r\n idRecepteur = "); |
chevamax | 16:1643ac8ba29f | 30 | for(int i=0; i < 8; i++){ |
chevamax | 16:1643ac8ba29f | 31 | if(getiemebit1(trameRecu[0], i)){ |
chevamax | 16:1643ac8ba29f | 32 | debug("1"); |
chevamax | 16:1643ac8ba29f | 33 | } |
chevamax | 16:1643ac8ba29f | 34 | else{ |
chevamax | 16:1643ac8ba29f | 35 | debug("0"); |
chevamax | 16:1643ac8ba29f | 36 | } |
chevamax | 16:1643ac8ba29f | 37 | } |
chevamax | 16:1643ac8ba29f | 38 | debug("\r\n niveauCuve = "); |
chevamax | 16:1643ac8ba29f | 39 | for(int i=0; i < 8; i++){ |
chevamax | 16:1643ac8ba29f | 40 | if(getiemebit1(niveauCuve, i)){ |
chevamax | 16:1643ac8ba29f | 41 | debug("1"); |
chevamax | 16:1643ac8ba29f | 42 | } |
chevamax | 16:1643ac8ba29f | 43 | else{ |
chevamax | 16:1643ac8ba29f | 44 | debug("0"); |
chevamax | 16:1643ac8ba29f | 45 | } |
chevamax | 16:1643ac8ba29f | 46 | } |
chevamax | 16:1643ac8ba29f | 47 | debug("\r\n dernierOctet = "); |
chevamax | 16:1643ac8ba29f | 48 | for(int i=0; i < 8; i++){ |
chevamax | 16:1643ac8ba29f | 49 | if(getiemebit1(trameRecu[2], i)){ |
chevamax | 16:1643ac8ba29f | 50 | debug("1"); |
chevamax | 16:1643ac8ba29f | 51 | } |
chevamax | 16:1643ac8ba29f | 52 | else{ |
chevamax | 16:1643ac8ba29f | 53 | debug("0"); |
chevamax | 16:1643ac8ba29f | 54 | } |
chevamax | 16:1643ac8ba29f | 55 | } |
chevamax | 16:1643ac8ba29f | 56 | debug("\r\n");*/ |
chevamax | 16:1643ac8ba29f | 57 | } |
chevamax | 16:1643ac8ba29f | 58 | char* Ordre::creerTrame(){ |
chevamax | 16:1643ac8ba29f | 59 | //TODO |
chevamax | 16:1643ac8ba29f | 60 | return NULL; |
chevamax | 16:1643ac8ba29f | 61 | } |
chevamax | 16:1643ac8ba29f | 62 | void Ordre::mettreAJourNiveauCuve(){ |
chevamax | 16:1643ac8ba29f | 63 | //TODO |
chevamax | 16:1643ac8ba29f | 64 | } |
chevamax | 16:1643ac8ba29f | 65 | |
chevamax | 16:1643ac8ba29f | 66 | char Ordre::getIdEmetteur(){ |
chevamax | 16:1643ac8ba29f | 67 | return idEmetteur; |
chevamax | 16:1643ac8ba29f | 68 | } |
chevamax | 16:1643ac8ba29f | 69 | char Ordre::getIdRecepteur(){ |
chevamax | 16:1643ac8ba29f | 70 | return idRecepteur; |
chevamax | 16:1643ac8ba29f | 71 | } |
chevamax | 16:1643ac8ba29f | 72 | char Ordre::getNiveauCuve(){ |
chevamax | 16:1643ac8ba29f | 73 | return niveauCuve; |
chevamax | 16:1643ac8ba29f | 74 | } |
chevamax | 16:1643ac8ba29f | 75 | char Ordre::getOrdreAFaire(){ |
chevamax | 16:1643ac8ba29f | 76 | return ordreAFaire; |
chevamax | 16:1643ac8ba29f | 77 | } |