diff options
Diffstat (limited to 'plugins/common/canadapter.h')
-rw-r--r-- | plugins/common/canadapter.h | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/plugins/common/canadapter.h b/plugins/common/canadapter.h new file mode 100644 index 00000000..fa78c102 --- /dev/null +++ b/plugins/common/canadapter.h @@ -0,0 +1,90 @@ +/* +Copyright (C) 2012 Intel Corporation + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef CANADAPTER_H +#define CANADAPTER_H + +/** + * \addtogroup libcanbus + * @{ + */ + +#include <linux/can.h> + +class CANObserver; + +/** +* \brief Abstracts CAN hardware object representation. +* Has protected constructor. +* Instance of the object has to be done via CANAdapter#createCANAdapter method. +* +* @code CANAdapter* pAdapter = CANAdapter::createCANAdapter(this); @endcode +* +* @class CANAdapter +*/ +class CANAdapter +{ +public: + virtual ~CANAdapter();/*LCOV_EXCL_LINE*/ + /** + * Creates and initializes CANAdapter instance + * @fn createCANAdapter + * @param observer @link CANObserver Observer @endlink that will receives CAN bus frames + * @return Pointer to CANAdapter instance + * @static + */ + static CANAdapter* createCANAdapter(CANObserver& observer); + /** + * Starts listening to CAN bus on the specified interface + * @fn start + * @param name Name of the CAN bus interface + * @return True if no error occurs. + */ + virtual bool start(const char* name) = 0; + /** + * Stops listening to CAN bus + * @fn stop + */ + virtual void stop() = 0; + /** + * Sends CAN frame over the bus + * @fn sendFrame + * @param frame CAN frame to be sent + * @return True if frame was sent + */ + virtual bool sendFrame(const can_frame& frame) = 0; + +protected: + /** + * @param observer @link CANObserver Observer @endlink that will receives CAN bus frames + */ + CANAdapter(CANObserver& observer); + +protected: + /** + * #CANObserver instance reference + * @property mObserver + * @protected + */ + CANObserver& mObserver; + +}; + +#endif // CANADAPTER_H + +/** @} */ |