summaryrefslogtreecommitdiff
path: root/i/marvin/src
diff options
context:
space:
mode:
authordufourj2006-01-11 16:36:37 +0000
committerdufourj2006-01-11 16:36:37 +0000
commit4f79f26d01e196411d4d59bd6ae9dbff23706f1f (patch)
tree249160f4ebb3828d2a713d7392e8dabaa92c2d62 /i/marvin/src
parent3cc65a4aa5299558dab3308bcba82f0480855a35 (diff)
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.
Diffstat (limited to 'i/marvin/src')
-rw-r--r--i/marvin/src/asserv/test_asserv.cc4
-rw-r--r--i/marvin/src/motor/motor.cc4
-rw-r--r--i/marvin/src/motor/motor.hh2
-rw-r--r--i/marvin/src/motor/test_motor.cc16
-rw-r--r--i/marvin/src/proto/proto.cc16
-rw-r--r--i/marvin/src/proto/proto.hh2
6 files changed, 16 insertions, 28 deletions
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<uint8_t>::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_;