diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-04-26 15:45:14 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-04-27 01:03:34 +0200 |
commit | f741d262ecd237121cc8cceb0f0893daa70bdf32 (patch) | |
tree | a22d7a36ef1dd5ae3f8b63b8fd9192297f18e7f5 /CAN-binder/low-can-binding/utils/socketcan.cpp | |
parent | 72f7ebbc61f36d6140114b3b9e403635cbe8baba (diff) |
Make template from similar writing stream operations.
Change-Id: I33b32418980059b701d2af5b165af536f42d0252
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'CAN-binder/low-can-binding/utils/socketcan.cpp')
-rw-r--r-- | CAN-binder/low-can-binding/utils/socketcan.cpp | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/CAN-binder/low-can-binding/utils/socketcan.cpp b/CAN-binder/low-can-binding/utils/socketcan.cpp index c462f76a..c550f6ed 100644 --- a/CAN-binder/low-can-binding/utils/socketcan.cpp +++ b/CAN-binder/low-can-binding/utils/socketcan.cpp @@ -17,13 +17,11 @@ #include <unistd.h> #include <string> -#include <string.h> #include <linux/can/raw.h> #include <net/if.h> #include <sys/ioctl.h> #include "socketcan.hpp" -#include "low-can-binding.hpp" #include "can-message.hpp" namespace utils @@ -144,7 +142,7 @@ namespace utils { struct { struct bcm_msg_head msg_head; - struct canfd_frame frames; + struct can_frame frames; } msg; struct sockaddr_can addr = s.get_tx_address(); @@ -158,27 +156,8 @@ namespace utils printf("Data available: %i bytes read\n", (int)nbytes); printf("read: Found on bus %s:\n id: %X, length: %X, data %02X%02X%02X%02X%02X%02X%02X%02X\n", ifr.ifr_name, msg.msg_head.can_id, msg.frames.len, msg.frames.data[0], msg.frames.data[1], msg.frames.data[2], msg.frames.data[3], msg.frames.data[4], msg.frames.data[5], msg.frames.data[6], msg.frames.data[7]); - return s; - } - - socketcan_t& operator<<(socketcan_t& s, const struct bcm_msg_head& obj) - { - struct sockaddr_can addr = s.get_tx_address(); - ::sendto(s.socket(), &obj, sizeof(bcm_msg_head), 0, (struct sockaddr*)&addr, sizeof(addr)); - return s; - } - socketcan_t& operator<<(socketcan_t& s, const struct canfd_frame& obj) - { - struct sockaddr_can addr = s.get_tx_address(); - ::sendto(s.socket(), &obj, sizeof(canfd_frame), 0, (struct sockaddr*)&addr, sizeof(addr)); - return s; - } - - socketcan_t& operator<<(socketcan_t& s, const struct can_frame& obj) - { - struct sockaddr_can addr = s.get_tx_address(); - ::sendto(s.socket(), &obj, sizeof(can_frame), 0, (struct sockaddr*)&addr, sizeof(addr)); + return s; } |