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 CANSOCKETRAW_H
20 #define CANSOCKETRAW_H
23 * \addtogroup libcanbus
30 #include <linux/can/raw.h>
32 #include "cansocket.h"
35 * \brief CAN Socket wrapper.
38 class CANSocketRaw : public CANSocket
44 * Opens and initializes CAN socket
46 * @param ifName Name of the CAN bus network interface.
47 * @return True if no error occurs.
49 virtual bool start(const char* ifName);
56 * Writes CAN frame using the socket
58 * @param message CAN frame with additional information
59 * @return True if no error occurs.
61 virtual bool write(const struct CANFrameInfo &message);
63 * Try to read CAN frame
65 * @param message Buffer for CAN frame with additional information
66 * @param timeout Timeout for reading in [ms].
67 * @return Reading operation status code.
69 virtual CANSocket::CANSocketReadSuccess read(struct CANFrameInfo& message, unsigned int timeout = 1000);
76 bool enableCANErrors(can_err_mask_t errorMask);
77 bool enableTimestamps();
78 bool locateInterfaceIndex(struct ifreq& ifr);
79 bool bindSocket(struct sockaddr_can &addr);
81 int waitData(unsigned int timeout);
82 bool writeFrame(const struct can_frame &frame);
83 ssize_t readFrame(can_frame& frame, double ×tamp);
87 * Socket file descriptor.
93 * Data structure describing a polling request.
100 #endif // CANSOCKETRAW_H