From 4f79f26d01e196411d4d59bd6ae9dbff23706f1f Mon Sep 17 00:00:00 2001 From: dufourj Date: Wed, 11 Jan 2006 16:36:37 +0000 Subject: i/marvin : - importation des modification des sync fait dans robert. doc/subversion : - rajout de la signification de X pour le status ; - lien pour la documentation officielle. --- i/marvin/src/asserv/test_asserv.cc | 4 ++-- i/marvin/src/motor/motor.cc | 4 +++- i/marvin/src/motor/motor.hh | 2 +- i/marvin/src/motor/test_motor.cc | 16 ++-------------- i/marvin/src/proto/proto.cc | 16 +++++++--------- i/marvin/src/proto/proto.hh | 2 +- 6 files changed, 16 insertions(+), 28 deletions(-) (limited to 'i') diff --git a/i/marvin/src/asserv/test_asserv.cc b/i/marvin/src/asserv/test_asserv.cc index 228748c..6d4e672 100644 --- a/i/marvin/src/asserv/test_asserv.cc +++ b/i/marvin/src/asserv/test_asserv.cc @@ -311,7 +311,8 @@ main (int argc, char **argv) break; } } - asserv.sync(); + while (!asserv.wait ()) + ; break; } case 'w': @@ -325,7 +326,6 @@ main (int argc, char **argv) { asserv.wait (stop - t); t = Timer::getProgramTime (); - asserv.sync(); } break; } diff --git a/i/marvin/src/motor/motor.cc b/i/marvin/src/motor/motor.cc index c292e9c..7e78aff 100644 --- a/i/marvin/src/motor/motor.cc +++ b/i/marvin/src/motor/motor.cc @@ -206,9 +206,11 @@ bool Motor::sync(void) return false; } -void Motor::wait(int timeout) +bool +Motor::wait(int timeout) { asserv_.wait(timeout); + return sync (); } /// Récupère le File Descriptor diff --git a/i/marvin/src/motor/motor.hh b/i/marvin/src/motor/motor.hh index b527525..ad67f84 100644 --- a/i/marvin/src/motor/motor.hh +++ b/i/marvin/src/motor/motor.hh @@ -100,7 +100,7 @@ class Motor : public Asserv::Receiver /// Syncronisation bool sync(void); /// On attend... - void wait(int timeout); + bool wait(int timeout = -1); /// Récupère le File Descriptor int getFd(void); /// Retoure l'état du jack (false entrée et true sortie) diff --git a/i/marvin/src/motor/test_motor.cc b/i/marvin/src/motor/test_motor.cc index 137e355..f01e299 100644 --- a/i/marvin/src/motor/test_motor.cc +++ b/i/marvin/src/motor/test_motor.cc @@ -112,20 +112,9 @@ main (int argc, char **argv) throw std::runtime_error("syntax error"); motor.setAccel(strtol(argv[0], 0, 10)); break; - case 'L': - while(!motor.idle()) - { - motor.wait(-1); - motor.sync(); - } - break; - } - motor.sync(); - while(!motor.idle()) - { - motor.wait(-1); - motor.sync(); } + while(!motor.wait () || !motor.idle ()) + ; break; } @@ -140,7 +129,6 @@ main (int argc, char **argv) { motor.wait (stop - t); t = Timer::getProgramTime (); - motor.sync(); } break; } diff --git a/i/marvin/src/proto/proto.cc b/i/marvin/src/proto/proto.cc index a7ada32..3569a47 100644 --- a/i/marvin/src/proto/proto.cc +++ b/i/marvin/src/proto/proto.cc @@ -56,11 +56,10 @@ Proto::close(void) bool Proto::sync(void) { - bool reGet; // Récupération de la frame - while (reGet = getFrame()) + while (getFrame()) { - //log_ ("recv") << "frame" << currentFrame_; +// log_ ("recv") << "frame" << currentFrame_; // Si la frame est un aquittement if(currentFrame_ == frameQueue_.front()) { @@ -96,7 +95,6 @@ Proto::send (const Frame & frame, bool reliable) } else sendFrame(frame); - // XXX sync(); } @@ -197,7 +195,8 @@ bool Proto::wait (int timeout/*-1*/) { // On apelle serial_.wait avec un timeout toujours inf ou égal à proto::timeout_ - return serial_.wait (timeout < timeout_ ? timeout : timeout_); + serial_.wait (timeout < timeout_ && timeout != -1 ? timeout : timeout_); + return sync (); } /// Récupère le File Descriptor @@ -241,7 +240,6 @@ Proto::getFrame(void) currentFrame_.command = receivedChar; revState_ = 2; } - // On vérifie que le match n'est pas fini break; case 2: d = hex2digit (receivedChar); @@ -270,7 +268,7 @@ Proto::getFrame(void) { // On renvoie en mettant le compteur à 0, la commande sera // renvoyer de retour à sync - //log_("Erreur de reception") << "commande inconnue" << ""; +// log_("Erreur de reception") << "commande inconnue" << ""; tLastSend_ = 0; revState_ = 0; return false; @@ -283,7 +281,7 @@ Proto::getFrame(void) void Proto::sendFrame(const Frame & frame) { - //log_ ("send") << "frame" << frame; +// log_ ("send") << "frame" << frame; // envoyer le bang serial_.putchar('!'); @@ -292,7 +290,7 @@ Proto::sendFrame(const Frame & frame) // Envoyer les arguments for(std::vector::const_iterator it = frame.args.begin(); - it != frame.args.end(); it++) + it != frame.args.end(); ++it) { serial_.putchar(digit2hex(*it >> 4)); serial_.putchar(digit2hex(*it & 0x0f)); diff --git a/i/marvin/src/proto/proto.hh b/i/marvin/src/proto/proto.hh index 11b1ae3..47ef9a0 100644 --- a/i/marvin/src/proto/proto.hh +++ b/i/marvin/src/proto/proto.hh @@ -55,7 +55,7 @@ class Proto : public NonCopyable //Date du dernier envoie int tLastSend_; //Temps entre les ré-émission - static const int timeout_ = 500; + static const int timeout_ = 100; /// Frame en cours de réception Frame currentFrame_; -- cgit v1.2.3