//============================================================================ // Name: // libcanio.h // // Summary: // A pretty simple interface to the SocketCan layer, // which trys to make the communication with the can interfaces easier. // // Created on: // Sep 24, 2010 // // Author: // Christian Steiger //============================================================================ #ifndef LIBCANIO_H_ #define LIBCANIO_H_ #include #include #include #include #include #include #include #include #include #include #include #include class CanIO { public: // constructor and destructor CanIO(); virtual ~CanIO(); // connect and disconnect int connect(const char* const interface = "can0"); int disconnect(void); // read and write messages ssize_t readMsg(can_frame* frame, timeval* timestamp = 0); ssize_t writeMsg(const can_frame* const frame); // socketcan options int showCanErrors(const can_err_mask_t err_mask = 0); int hideCanErrors(void); int enableLoopBack(void); int disableLoopBack(void); int enableRecvOwnMsgs(void); int disableRecvOwnMsgs(void); // filter functions int addFilter(const can_filter* const filter, const unsigned int size); int enableFilter(void); int disableFilter(void); int clearFilter(void); // debugging help void hideErrors(void); void showErrors(void); protected: // class members int m_socket; char m_print_errors; char m_filter_active; can_filter* m_filter; unsigned short int m_filter_size; private: // dont use this function, it will be obsolete when // the filter functions get a better implementation char isVisible(const unsigned int id); }; #endif