1 #ifndef H_CAN_INTERFACE 2 #define H_CAN_INTERFACE 4 #include <boost/array.hpp> 5 #include <boost/system/error_code.hpp> 6 #include <boost/shared_ptr.hpp> 14 static const unsigned int ID_MASK = (1u << 29)-1;
16 static const unsigned int RTR_MASK = (1u << 30);
38 Header(
unsigned int i,
bool extended,
bool rtr,
bool error)
58 boost::array<value_type, 8>
data;
75 value_type *
c_array() {
return data.c_array(); }
76 const value_type *
c_array()
const {
return data.data(); }
88 State() : driver_state(closed), internal_error(0) {}
89 virtual bool isReady()
const {
return driver_state == ready; }
94 template <
typename T,
typename U>
class Listener{
103 void operator()(
const U & u)
const {
if(callable_) callable_(u); }
119 virtual StateListenerConstSharedPtr createStateListener(
const StateDelegate &delegate) = 0;
138 virtual bool send(
const Frame & msg) = 0;
146 virtual FrameListenerConstSharedPtr createMsgListener(
const FrameDelegate &delegate) = 0;
155 virtual FrameListenerConstSharedPtr createMsgListener(
const Frame::Header&,
const FrameDelegate &delegate) = 0;
172 virtual bool init(
const std::string &device,
bool loopback) = 0;
179 virtual bool recover() = 0;
184 virtual State getState() = 0;
191 virtual void shutdown() = 0;
193 virtual bool translateError(
unsigned int internal_error, std::string & str) = 0;
195 virtual bool doesLoopBack()
const = 0;
197 virtual void run() = 0;
207 #include <boost/thread/mutex.hpp> 211 static boost::mutex mutex;
216 #define LOG(log) { boost::mutex::scoped_lock _cout_lock(_cout_wrapper::get_cout_mutex()); std::cout << log << std::endl; } static boost::mutex & get_cout_mutex()
fastdelegate::FastDelegate1< const State & > StateDelegate
Frame(const Header &h, unsigned char l=0)
const value_type * c_array() const
boost::array< value_type, 8 > data
array for 8 data bytes with bounds checking
Listener< const StateDelegate, const State & > StateListener
boost::shared_ptr< CommInterface > CommInterfaceSharedPtr
Listener(const T &callable)
void operator()(const U &u) const
boost::shared_ptr< DriverInterface > DriverInterfaceSharedPtr
fastdelegate::FastDelegate1< const Frame & > FrameDelegate
virtual ~StateInterface()
StateListener::ListenerConstSharedPtr StateListenerConstSharedPtr
CommInterface::FrameListenerConstSharedPtr FrameListenerConstSharedPtr
ListenerConstSharedPtr Ptr __attribute__((deprecated))
virtual bool isReady() const
virtual ~DriverInterface()
boost::shared_ptr< const Listener > ListenerConstSharedPtr
unsigned int internal_error
driver specific error
Listener< const FrameDelegate, const Frame & > FrameListener
StateInterface::StateListenerConstSharedPtr StateListenerConstSharedPtr
unsigned char dlc
len of data
FrameListener::ListenerConstSharedPtr FrameListenerConstSharedPtr
boost::shared_ptr< StateInterface > StateInterfaceSharedPtr
void run(ClassLoader *loader)
boost::system::error_code error_code
device access error