summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/proto/proto.cc
diff options
context:
space:
mode:
authorhaller2005-04-09 22:42:58 +0000
committerhaller2005-04-09 22:42:58 +0000
commit98f2eebf37b6bed5797a35f45039e9da7542e1df (patch)
tree105af03961c1373a88b2cd061efaa4e3092b186e /2005/i/robert/src/proto/proto.cc
parentcbdfded9991dc3e01da3f70cd81b854694c0f769 (diff)
Corrections de quelques bugs
Diffstat (limited to '2005/i/robert/src/proto/proto.cc')
-rw-r--r--2005/i/robert/src/proto/proto.cc44
1 files changed, 22 insertions, 22 deletions
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<uint8_t>(hex2digit( receivedChar )))
- << 4;
- revState_ = 2;
- break;
- case 2:
- currentFrame_.command |= static_cast<uint8_t>(hex2digit(
- receivedChar ));
- revState_ = 3;
- break;
- case 3:
- currentFrame_.args.push_back(static_cast<uint8_t>(
- 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<uint8_t>(
+ hex2digit( receivedChar )) << 4);
+ revState_ = 3;
+ break;
+ case 3:
+ *(currentFrame_.args.end()) |= static_cast<uint8_t>(
+ hex2digit( receivedChar ));
+ revState_ = 2;
+ break;
+ }
//Si revState == 0 alors on jette
}
}