From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- Master/Real-Time Systems/mki/src/libcanio.h | 81 +++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 Master/Real-Time Systems/mki/src/libcanio.h (limited to 'Master/Real-Time Systems/mki/src/libcanio.h') diff --git a/Master/Real-Time Systems/mki/src/libcanio.h b/Master/Real-Time Systems/mki/src/libcanio.h new file mode 100644 index 0000000..8f57b14 --- /dev/null +++ b/Master/Real-Time Systems/mki/src/libcanio.h @@ -0,0 +1,81 @@ +//============================================================================ +// 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 -- cgit v1.2.3