aboutsummaryrefslogtreecommitdiffstats
path: root/CAN-binder/low-can-binding
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-04-20 17:38:01 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-04-20 17:38:01 +0200
commit0a27582743cb7b4ad191adea4eefeda01d179896 (patch)
tree9187fa3ee5ca4351fac72b8bceb63760769f0f9c /CAN-binder/low-can-binding
parentf546e121079088920e2a3f64bc054afa05ff945f (diff)
Use same function to open BCM and RAW CAN sockets
Using one a another socket type is made using a boolean. Change-Id: I0445c8550f289d1e0020f6496c638bc95e8db443 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'CAN-binder/low-can-binding')
-rw-r--r--CAN-binder/low-can-binding/can/can-bus-dev.cpp8
-rw-r--r--CAN-binder/low-can-binding/can/can-bus-dev.hpp2
-rw-r--r--CAN-binder/low-can-binding/can/can-bus.cpp2
3 files changed, 6 insertions, 6 deletions
diff --git a/CAN-binder/low-can-binding/can/can-bus-dev.cpp b/CAN-binder/low-can-binding/can/can-bus-dev.cpp
index 6fab8e9d..a1c6fcda 100644
--- a/CAN-binder/low-can-binding/can/can-bus-dev.cpp
+++ b/CAN-binder/low-can-binding/can/can-bus-dev.cpp
@@ -51,14 +51,14 @@ uint32_t can_bus_dev_t::get_address() const
/// timestamp received messages and pass the socket to FD mode.
///
/// @return -1 if something wrong.
-int can_bus_dev_t::open_raw()
+int can_bus_dev_t::open(bool bcm)
{
const int canfd_on = 1;
const int timestamp_on = 1;
struct timeval timeout;
DEBUG(binder_interface, "open_raw: CAN Handler socket : %d", can_socket_.socket());
- can_socket_.open(device_name_);
+ return can_socket_.open(device_name_, bcm);
// Set some option on the socket : timeout, timestamp and canfd frame usage.
if (can_socket_)
@@ -186,7 +186,7 @@ int can_bus_dev_t::send(can_message_t& can_msg)
else
{
ERROR(binder_interface, "send_can_message: socket not initialized. Attempt to reopen can device socket.");
- open_raw();
+ open(true);
return -1;
}
return 0;
@@ -224,7 +224,7 @@ bool can_bus_dev_t::shims_send(const uint32_t arbitration_id, const uint8_t* dat
else
{
ERROR(binder_interface, "send_can_message: socket not initialized. Attempt to reopen can device socket.");
- open_raw();
+ open(true);
}
return false;
}
diff --git a/CAN-binder/low-can-binding/can/can-bus-dev.hpp b/CAN-binder/low-can-binding/can/can-bus-dev.hpp
index 3e6b2d1c..8cafaf83 100644
--- a/CAN-binder/low-can-binding/can/can-bus-dev.hpp
+++ b/CAN-binder/low-can-binding/can/can-bus-dev.hpp
@@ -50,7 +50,7 @@ public:
std::string get_device_name() const;
uint32_t get_address() const;
- int open_raw();
+ int open(bool bcm=false);
int close();
void start_reading(can_bus_t& can_bus);
diff --git a/CAN-binder/low-can-binding/can/can-bus.cpp b/CAN-binder/low-can-binding/can/can-bus.cpp
index 90d4c74f..4775b4fe 100644
--- a/CAN-binder/low-can-binding/can/can-bus.cpp
+++ b/CAN-binder/low-can-binding/can/can-bus.cpp
@@ -237,7 +237,7 @@ int can_bus_t::init_can_dev()
for(const auto& device : devices_name)
{
can_bus_t::can_devices_[device] = std::make_shared<can_bus_dev_t>(device, i);
- if (can_bus_t::can_devices_[device]->open_raw() == 0)
+ if (can_bus_t::can_devices_[device]->open(true) >= 0)
{
DEBUG(binder_interface, "Start reading thread");
NOTICE(binder_interface, "%s device opened and reading", device.c_str());