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
21 /* Refactored to an abstract interface. See http://stackoverflow.com/a/825365 */
27 * @defgroup libcanbus libcanbus static library
28 * \brief SocketCAN based CAN bus library.
32 #include "canobserver.h"
35 * \brief Encapsulation of the raw CAN bus.
42 virtual ~CANBus(){} /*LCOV_EXCL_LINE*/
45 * Starts the CAN bus instance on the specified interface
47 * @param name Name of the CAN bus network interface
48 * @return True if no error occurs.
50 virtual bool start(const char* name) = 0;
52 * Stops the CAN bus instance
55 virtual void stop() = 0;
57 * Sends standard(11bit) CAN frame over the bus
58 * @fn sendStandardFrame
59 * @param frame CAN frame to be sent
60 * @return True if frame was sent
62 virtual bool sendStandardFrame(const can_frame& frame) = 0;
64 * Sends extended(29bit) CAN frame over the bus
65 * @fn sendExtendedFrame
66 * @param frame CAN frame to be sent
67 * @return True if frame was sent
69 virtual bool sendExtendedFrame(const can_frame& frame) = 0;
71 * Registers CAN ID of a cyclic message for receiving
72 * @fn registerCyclicMessageForReceive
73 * @param canId CAN ID of the message.
74 * @param minCycleTime Minimal interval between messages in seconds. Set to 0 if not used.
75 * @param maxCycleTime Maximum interval between messages for timeout detection in seconds. Set to 0 if no timeout detection is necessary.
76 * @return True if registration succeeds.
78 virtual bool registerCyclicMessageForReceive(int canId, double minCycleTime, double maxCycleTime) = 0;
80 * Registers CAN ID of a message for receiving with no timeout. Perfect for sporadic messages.
81 * @fn registerMessageForReceive
82 * @param canId CAN ID of the message.
83 * @return True if registration succeeds.
85 virtual bool registerMessageForReceive(int canId)
87 return registerCyclicMessageForReceive(canId, 0, 0);
90 * Un-registers CAN ID of a message used of receiving. Valid for cyclic and sporadic messages.
91 * @fn unregisterMessageForReceive
92 * @param canId CAN ID of the message.
93 * @return True if de-registration succeeds.
95 virtual bool unregisterMessageForReceive(int canId) = 0;