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
23 * \addtogroup libcanbus
30 #include <linux/can/raw.h>
33 * \brief CAN Socket wrapper.
41 * CAN bus socket error.
42 * @enum CANSocketReadSuccess
45 enum CANSocketReadSuccess {
56 * Opens and initialize CAN socket
58 * @param ifName Name of the CAN bus network interface.
59 * @return True if no error occurs.
61 virtual bool start(const char* ifName);
68 * Writes CAN frame using the socket
70 * @param frame CAN frame buffer
71 * @param bytesWritten Number of written bytes.
72 * @return True if no error occurs.
74 virtual bool write(const struct can_frame &frame, int &bytesWritten);
77 * Try to read CAN frame
79 * @param frame CAN frame buffer
80 * @param bytesRead Number of read bytes.
81 * @param timeout Timeout for reading.
82 * @return Reading operation status code.
84 virtual CANSocket::CANSocketReadSuccess read( struct can_frame& frame, int &bytesRead, unsigned int timeout = 1000);
90 virtual bool createSocket();
91 virtual bool enableCANErrors(can_err_mask_t errorMask);
92 virtual bool locateInterfaceIndex(struct ifreq& ifr);
93 virtual bool bindSocket(struct sockaddr_can &addr);
94 virtual bool closeSocket();
95 virtual int waitData(unsigned int timeout);
96 virtual ssize_t writeFrame(const struct can_frame &frame);
97 virtual ssize_t readFrame(struct can_frame& frame);
101 * Socket file descriptor.
107 * Data structure describing a polling request.
114 #endif // CANSOCKET_H