socketcan_gateway.h
Go to the documentation of this file.
00001 
00025 #ifndef PUMA_MOTOR_DRIVER_SOCKETCAN_GATEWAY_H
00026 #define PUMA_MOTOR_DRIVER_SOCKETCAN_GATEWAY_H
00027 
00028 
00029 #include <string>
00030 #include <stdio.h>
00031 #include <unistd.h>
00032 #include <fcntl.h>
00033 #include <poll.h>
00034 #include <sys/types.h>
00035 #include <sys/socket.h>
00036 #include <sys/ioctl.h>
00037 #include <sys/select.h>
00038 #include <net/if.h>
00039 
00040 #include <linux/can.h>
00041 #include <linux/can/raw.h>
00042 
00043 #include "puma_motor_driver/gateway.h"
00044 #include "puma_motor_driver/message.h"
00045 
00046 namespace puma_motor_driver
00047 {
00048 
00049 class SocketCANGateway : public Gateway
00050 {
00051 public:
00052   explicit SocketCANGateway(std::string canbus_dev);
00053 
00054   virtual bool connect();
00055   virtual bool isConnected();
00056 
00057   virtual bool recv(Message* msg);
00058   virtual void queue(const Message& msg);
00059   virtual bool sendAllQueued();
00060   void msgToFrame(Message* msg, can_frame* frame);
00061 
00062 private:
00063   int socket_;
00064   std::string canbus_dev_;  // CAN interface ID
00065   bool is_connected_;
00066 
00067   can_frame write_frames_[1024];
00068   int write_frames_index_;
00069 };
00070 
00071 }  // namespace puma_motor_driver
00072 
00073 #endif  // PUMA_MOTOR_DRIVER_SOCKETCAN_GATEWAY_H


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