2 Copyright (C) 2012 Intel Corporation
3 Copyright (C) 2015 Cogent Embedded Inc.
4 Copyright (C) 2015 Renesas Electronics Corporation
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 * \addtogroup libcanbus
29 #include <linux/can.h>
34 * \brief Abstracts CAN hardware object representation.
35 * Has protected constructor.
36 * Instance of the object has to be done via CANAdapter#createCANAdapter method.
38 * @code CANAdapter* pAdapter = CANAdapter::createCANAdapter(this); @endcode
45 virtual ~CANAdapter();/*LCOV_EXCL_LINE*/
47 * Creates and initializes CANAdapter instance
48 * @fn createCANAdapter
49 * @param observer @link CANObserver Observer @endlink that will receives CAN bus frames
50 * @return Pointer to CANAdapter instance
53 static CANAdapter* createCANAdapter(CANObserver& observer);
55 * Starts listening to CAN bus on the specified interface
57 * @param name Name of the CAN bus interface
58 * @return True if no error occurs.
60 virtual bool start(const char* name) = 0;
62 * Stops listening to CAN bus
65 virtual void stop() = 0;
67 * Sends CAN frame over the bus
69 * @param frame CAN frame to be sent
70 * @return True if frame was sent
72 virtual bool sendFrame(const can_frame& frame) = 0;
74 * Registers CAN ID of a cyclic message for receiving
75 * @fn registerCyclicMessageForReceive
76 * @param canId CAN ID of the message.
77 * @param minCycleTime Minimal interval between messages in seconds. Set to 0 if not used.
78 * @param maxCycleTime Maximum interval between messages for timeout detection in seconds. Set to 0 if no timeout detection is necessary.
79 * @return True if registration succeeds.
81 virtual bool registerCyclicMessageForReceive(int canId, double minCycleTime, double maxCycleTime) = 0;
83 * Un-registers CAN ID of a message used of receiving. Valid for cyclic and sporadic messages.
84 * @fn unregisterMessageForReceive
85 * @param canId CAN ID of the message.
86 * @return True if de-registration succeeds.
88 virtual bool unregisterMessageForReceive(int canId) = 0;
92 * @param observer @link CANObserver Observer @endlink that will receives CAN bus frames
94 CANAdapter(CANObserver& observer);
98 * #CANObserver instance reference
102 CANObserver& mObserver;
106 #endif // CANADAPTER_H