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
19 #ifndef CANSOCKETADAPTER_H
20 #define CANSOCKETADAPTER_H
23 * \addtogroup libcanbus
27 #include "canadapter.h"
31 class CANSocketReader;
34 * \brief Socket CAN device implementation based on <a href="http://developer.berlios.de/projects/socketcan">BerliOS Socket CAN</a> API.
36 * @class CANSocketAdapter
38 class CANSocketAdapter : public CANAdapter
42 * @param observer @link CANObserver Observer @endlink that will receives CAN bus frames
44 CANSocketAdapter(CANObserver& observer);
45 virtual ~CANSocketAdapter();
48 * Creates connection the specified network interface and starts listening on it.
50 * @param ifName Name of the CAN bus network interface
51 * @return True if no error occurs.
53 virtual bool start(const char* ifName);
55 * Closes socket connection and exits listening thread.
60 * Sends CAN frame over the socket CAN interface
62 * @param frame CAN frame to be sent
63 * @return True if frame was sent
65 virtual bool sendFrame(const can_frame& frame);
67 * Registers CAN ID of a cyclic message for receiving
68 * @fn registerCyclicMessageForReceive
69 * @param canId CAN ID of the message.
70 * @param minCycleTime Minimal interval between messages in seconds. Set to 0 if not used.
71 * @param maxCycleTime Maximum interval between messages for timeout detection in seconds. Set to 0 if no timeout detection is necessary.
72 * @return True if registration succeeds.
74 virtual bool registerCyclicMessageForReceive(int canId, double minCycleTime, double maxCycleTime);
76 * Un-registers CAN ID of a message used of receiving. Valid for cyclic and sporadic messages.
77 * @fn unregisterMessageForReceive
78 * @param canId CAN ID of the message.
79 * @return True if de-registration succeeds.
81 virtual bool unregisterMessageForReceive(int canId);
85 * Socket initialization and starts reading thread
93 * @link CANSocket CAN Socket wrapper @endlink instance reference
99 * @link CANSocketReader CANSocket reader @endlink instance reference
103 CANSocketReader* mReader;
106 #endif // CANSOCKETADAPTER_H