serial_gateway.h
Go to the documentation of this file.
00001 
00024 #ifndef PUMA_MOTOR_DRIVER_SERIAL_GATEWAY_H
00025 #define PUMA_MOTOR_DRIVER_SERIAL_GATEWAY_H
00026 
00027 #include "puma_motor_driver/gateway.h"
00028 #include "puma_motor_driver/message.h"
00029 #include "serial/serial.h"
00030 
00031 
00032 namespace puma_motor_driver
00033 {
00034 
00035 class SerialGateway : public Gateway
00036 {
00037 public:
00038   explicit SerialGateway(serial::Serial& serial);
00039 
00040   virtual bool connect();
00041   virtual bool isConnected();
00042 
00043   virtual bool recv(Message* msg);
00044   virtual void queue(const Message& msg);
00045   virtual bool sendAllQueued();
00046 
00047 private:
00048   serial::Serial& serial_;
00049 
00050   void queue(uint8_t ch);
00051   bool read(uint8_t* ch);
00052 
00053   void encodeAndQueue(const uint8_t* data, uint8_t len);
00054   bool readAndDecode(uint8_t* data, uint8_t len);
00055 
00056   uint8_t write_buffer_[1024];
00057   uint16_t write_buffer_index_;
00058 
00059   uint8_t read_buffer_[1024];
00060   uint16_t read_buffer_index_;
00061   uint16_t read_buffer_len_;
00062 };
00063 
00064 }  // namespace puma_motor_driver
00065 
00066 #endif  // PUMA_MOTOR_DRIVER_SERIAL_GATEWAY_H


puma_motor_driver
Author(s):
autogenerated on Sat Jun 8 2019 18:55:15