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
42 virtual ~CANSocketRaw(){} /*LCOV_EXCL_LINE*/
45 * Opens and initializes CAN socket
47 * @param ifName Name of the CAN bus network interface.
48 * @return True if no error occurs.
50 virtual bool start(const char* ifName);
57 * Writes CAN frame using the socket
59 * @param message CAN frame with additional information
60 * @return True if no error occurs.
62 virtual bool write(const struct CANFrameInfo &message);
64 * Try to read CAN frame
66 * @param message Buffer for CAN frame with additional information
67 * @param timeout Timeout for reading in [ms].
68 * @return Reading operation status code.
70 virtual CANSocket::CANSocketReadSuccess read(struct CANFrameInfo& message, unsigned int timeout = 1000);
77 bool enableCANErrors(can_err_mask_t errorMask);
78 bool enableTimestamps();
79 bool locateInterfaceIndex(struct ifreq& ifr);
80 bool bindSocket(struct sockaddr_can &addr);
82 int waitData(unsigned int timeout);
83 bool writeFrame(const struct can_frame &frame);
84 ssize_t readFrame(can_frame& frame, double ×tamp);
88 * Socket file descriptor.
94 * Data structure describing a polling request.
101 #endif // CANSOCKETRAW_H