2 Copyright (C) 2012 Intel Corporation
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 * \addtogroup libcanbus
27 #include <linux/can.h>
32 * \brief Abstracts CAN hardware object representation.
33 * Has protected constructor.
34 * Instance of the object has to be done via CANAdapter#createCANAdapter method.
36 * @code CANAdapter* pAdapter = CANAdapter::createCANAdapter(this); @endcode
43 virtual ~CANAdapter();/*LCOV_EXCL_LINE*/
45 * Creates and initializes CANAdapter instance
46 * @fn createCANAdapter
47 * @param observer @link CANObserver Observer @endlink that will receives CAN bus frames
48 * @return Pointer to CANAdapter instance
51 static CANAdapter* createCANAdapter(CANObserver& observer);
53 * Starts listening to CAN bus on the specified interface
55 * @param name Name of the CAN bus interface
56 * @return True if no error occurs.
58 virtual bool start(const char* name) = 0;
60 * Stops listening to CAN bus
63 virtual void stop() = 0;
65 * Sends CAN frame over the bus
67 * @param frame CAN frame to be sent
68 * @return True if frame was sent
70 virtual bool sendFrame(const can_frame& frame) = 0;
74 * @param observer @link CANObserver Observer @endlink that will receives CAN bus frames
76 CANAdapter(CANObserver& observer);
80 * #CANObserver instance reference
84 CANObserver& mObserver;
88 #endif // CANADAPTER_H