X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=CAN-binder%2Flow-can-binding%2Fcan%2Fcan-bus-dev.cpp;h=601881db4918c7a719e0535aa497046d7f56c955;hb=ae74dbcb89f3d471b66e1f1d2fe4bdf33cfff388;hp=07f921f2758a9e1f64d31e47c4f4a5e621ead622;hpb=10e7cf8b0d84be658069f60e5dd4831ec202cd70;p=apps%2Fagl-service-can-low-level.git 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 07f921f2..601881db 100644 --- a/CAN-binder/low-can-binding/can/can-bus-dev.cpp +++ b/CAN-binder/low-can-binding/can/can-bus-dev.cpp @@ -24,9 +24,7 @@ #include "can-bus.hpp" #include "can-message.hpp" -#include "../low-can-binding.hpp" -#include "canutil/write.h" -#include "bitfield/bitfield.h" +#include "../binding/low-can-hat.hpp" /// @brief Class constructor /// @@ -67,8 +65,16 @@ void can_bus_dev_t::configure() if (can_socket_) { const int timestamp_on = 1; + const int canfd_on = 1; DEBUG(binder_interface, "%s: CAN Handler socket correctly initialized : %d", __FUNCTION__, can_socket_.socket()); + + // try to switch the socket into CAN_FD mode + if (can_socket_.setopt(SOL_CAN_RAW, CAN_RAW_FD_FRAMES, &canfd_on, sizeof(canfd_on)) < 0) + { + NOTICE(binder_interface, "%s: Can not switch into CAN Extended frame format: %s", __FUNCTION__, ::strerror(errno)); + } + if (can_socket_.setopt(SOL_SOCKET, SO_TIMESTAMP, ×tamp_on, sizeof(timestamp_on)) < 0) WARNING(binder_interface, "%s: setsockopt SO_TIMESTAMP error: %s", __FUNCTION__, ::strerror(errno)); } @@ -98,7 +104,7 @@ can_message_t can_bus_dev_t::read() // Test that socket is really opened if (!can_socket_) { - ERROR(binder_interface, "read: Socket unavailable. Closing thread."); + ERROR(binder_interface, "%s: Socket unavailable. Closing thread.", __FUNCTION__); is_running_ = false; } @@ -108,8 +114,8 @@ can_message_t can_bus_dev_t::read() if (nbytes != CANFD_MTU && nbytes != CAN_MTU) { if (errno == ENETDOWN) - ERROR(binder_interface, "read: %s CAN device down", device_name_.c_str()); - ERROR(binder_interface, "read: Incomplete CAN(FD) frame"); + ERROR(binder_interface, "%s: %s CAN device down", __FUNCTION__, device_name_.c_str()); + ERROR(binder_interface, "%s: Incomplete CAN(FD) frame", __FUNCTION__); ::memset(&cfd, 0, sizeof(cfd)); }