From 98f2eebf37b6bed5797a35f45039e9da7542e1df Mon Sep 17 00:00:00 2001 From: haller Date: Sat, 9 Apr 2005 22:42:58 +0000 Subject: Corrections de quelques bugs --- 2005/i/robert/src/proto/proto.cc | 44 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to '2005/i/robert/src/proto/proto.cc') diff --git a/2005/i/robert/src/proto/proto.cc b/2005/i/robert/src/proto/proto.cc index c0f95f7..0df2ab5 100644 --- a/2005/i/robert/src/proto/proto.cc +++ b/2005/i/robert/src/proto/proto.cc @@ -102,7 +102,7 @@ Proto::send (const Frame & frame, bool fiable) /// format et le nombre de paramètres ('b' : 8 bits, 'w' : 16 bits, 'd' : /// 32 bits, majuscule pour signé). void -Proto::send (uint8_t command, const char *format, int a0, int a1, +Proto::send (char command, const char *format, int a0, int a1, int a2, int a3, bool fiable) { // Constitution de la frame @@ -128,7 +128,7 @@ Proto::send (uint8_t command, const char *format, int a0, int a1, /// permet d'envoyer un packet pas fiable void -Proto::send_pas_fiable (uint8_t command, const char *format, int a0, int a1, +Proto::send_pas_fiable (char command, const char *format, int a0, int a1, int a2, int a3) { send(command, format, a0, a1, a2, a3, false); @@ -188,7 +188,7 @@ Proto::getFrame(void) while((receivedChar = serial_.getchar()) != -1) { //si la donnée n'est pas erronnée - if(receivedChar != 0xff) + if(receivedChar != 0xff) // XXX Heu, c'est vraiment ça????? { //Si on reçoit un bang if(receivedChar == '!') @@ -198,31 +198,31 @@ Proto::getFrame(void) currentFrame_.args.clear(); } //Si on reçoit le retour chariot et que on reçevait les args - if(receivedChar == '\n' && revState_ == 3) + else if(receivedChar == '\n' && revState_ == 2) { revState_ = 0; return true; } //Pour les autres charactères //Si on attend la commande - switch(revState_) - { - case 1: - currentFrame_.command = (static_cast(hex2digit( receivedChar ))) - << 4; - revState_ = 2; - break; - case 2: - currentFrame_.command |= static_cast(hex2digit( - receivedChar )); - revState_ = 3; - break; - case 3: - currentFrame_.args.push_back(static_cast( - hex2digit( receivedChar )) << 4); - revState_ = 3; - break; - } + else + switch(revState_) + { + case 1: + currentFrame_.command = receivedChar; + revState_ = 2; + break; + case 2: // XXX Bite de poids fort à gauche dans la frame?? + currentFrame_.args.push_back(static_cast( + hex2digit( receivedChar )) << 4); + revState_ = 3; + break; + case 3: + *(currentFrame_.args.end()) |= static_cast( + hex2digit( receivedChar )); + revState_ = 2; + break; + } //Si revState == 0 alors on jette } } -- cgit v1.2.3