diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-04-20 00:07:37 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-04-20 00:07:37 +0200 |
commit | f546e121079088920e2a3f64bc054afa05ff945f (patch) | |
tree | 4b966d3b97b3666cdb5b263c1b3be3f2b563db42 /CAN-binder/low-can-binding/utils/socket.hpp | |
parent | ff30daa04391f981e871f1dea27b6fbb2b91791c (diff) |
Specializing socket class to CAN socket operations.
Move all legacy opening RAW CAN socket operation to socket class. Each operations
on a CAN socket has to be simple and made by the socket class.
Simple BCM socket open operation is implemented.
Future will be to open specialized BCM CAN sockets on demand.
Change-Id: If285b97afb9871245ab1f13cd9f0401fbd9adf95
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'CAN-binder/low-can-binding/utils/socket.hpp')
-rw-r--r-- | CAN-binder/low-can-binding/utils/socket.hpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/CAN-binder/low-can-binding/utils/socket.hpp b/CAN-binder/low-can-binding/utils/socket.hpp index b42eee6a..2da2dfe5 100644 --- a/CAN-binder/low-can-binding/utils/socket.hpp +++ b/CAN-binder/low-can-binding/utils/socket.hpp @@ -23,24 +23,27 @@ namespace utils { - class socket_t + class socketcan_t { public: - socket_t(); - socket_t(const socket_t&) = delete; - socket_t(socket_t&&); - ~socket_t(); + socketcan_t(); + socketcan_t(const socketcan_t&) = delete; + socketcan_t(socketcan_t&&); + ~socketcan_t(); explicit operator bool() const; - int open(int domain, int type, int protocol); - int close(); - int setopt(int level, int optname, const void* optval, socklen_t optlen); int socket() const; - int bind(const struct sockaddr* addr, socklen_t len); - + int open(std::string device_name, bool bcm=false); + int setopt(int level, int optname, const void* optval, socklen_t optlen); + ssize_t send(const struct canfd_frame& f); + int close(); private: int socket_; + struct sockaddr_can txAddress_; /// < internal member using to bind to the socket + + int open(int domain, int type, int protocol); + int bind(const struct sockaddr* addr, socklen_t len); + int connect(const struct sockaddr* addr, socklen_t len); }; } - |