summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/proto/proto.hh
diff options
context:
space:
mode:
Diffstat (limited to '2005/i/robert/src/proto/proto.hh')
-rw-r--r--2005/i/robert/src/proto/proto.hh33
1 files changed, 19 insertions, 14 deletions
diff --git a/2005/i/robert/src/proto/proto.hh b/2005/i/robert/src/proto/proto.hh
index 6c304c1..19bf376 100644
--- a/2005/i/robert/src/proto/proto.hh
+++ b/2005/i/robert/src/proto/proto.hh
@@ -24,6 +24,9 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// }}}
+
+#include<queue>
+#include<stdint.h>
#include "utils/non_copyable.hh"
#include "serial/serial.hh"
@@ -31,7 +34,13 @@
class Proto : public NonCopyable
{
class Receiver;
- struct Frame;
+ /// Packet.
+ struct Frame
+ {
+ uint8_t command;
+ std::vector<uint8_t> args;
+ bool operator==(const Frame& frame);
+ };
Serial serial_;
Receiver &receiver_;
@@ -42,11 +51,13 @@ class Proto : public NonCopyable
/// Frame en cours de réception
Frame currentFrame_;
- int revState_ = 0;
+ int revState_;
// Etat de la réception de la frame
// 0 - Rien reçu
// 1 - Bang reçu
- // 2 - Commande reçu
+ // 2 - char 1 commande reçu
+ // 3 - Commande reçu & nouveau argument
+ // 4 - char 1 argument reçu
public:
/// Constructeur.
@@ -85,27 +96,21 @@ class Proto : public NonCopyable
/// Recoit un packet.
virtual void receive (uint8_t command, const Frame &frame) = 0;
};
- /// Packet.
- struct Frame
- {
- uint8_t command;
- std::vector<uint8_t> args;
- };
private:
/// Récupère les infos de l'AVR pour construire une frame
bool getFrame(void);
/// Envoie la frame dans l'AVR
void sendFrame(const Frame & frame);
/// Remplie une frame avec un argument
- void newArgFrame(Frame & frame, char format, int arg);
+ void newArgFrame(Proto::Frame & frame, char format, int arg);
/// Renvoie la taille necessaire du vecteur args pour un format donné
- int ArgsFrameSize(const char *format,int nbArg = 0);
+ static int ArgsFrameSize(const char *format,int nbArg = 0);
/// Renvoie la taille necessaire du vecteur args pour 1 argument
- int ArgSize(char format);
+ static int ArgSize(char format);
/// Vérifie le format de la frame
- bool verifyFrame(Frame &frame, const char *format, int nbArg);
+ static bool verifyFrame(const Frame &frame, const char *format, int nbArg);
/// Décode un argument
- int decodeArg(const Frame & frame, const char *format, int numArg);
+ static int decodeArg(const Frame & frame, const char *format, int numArg);
};
#endif // proto_hh