summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-03-01 17:06:17 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2017-03-01 17:06:17 +0100
commitd10240e4c0d05ae6ccd633f7b82cbdd48ec27d7c (patch)
tree2a01b179557949e1de3871718bf00f1b40413192 /src
parent834d1a950d38a821284955f2732cdbb5b05ebd2a (diff)
Fix: miss 'if' brackets to get incomplete CAN frames correctly
Fix: displaying can message frame with hexa format. Change-Id: Iff658ac38f21a15945ed82509d4e291f0fda7503 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src')
-rw-r--r--src/can-bus.cpp13
-rw-r--r--src/can-message.cpp2
2 files changed, 8 insertions, 7 deletions
diff --git a/src/can-bus.cpp b/src/can-bus.cpp
index 989dfa2..81dee9a 100644
--- a/src/can-bus.cpp
+++ b/src/can-bus.cpp
@@ -361,7 +361,7 @@ canfd_frame can_bus_dev_t::read()
{
ssize_t nbytes;
//int maxdlen;
- canfd_frame canfd_frame;
+ struct canfd_frame cfd;
/* Test that socket is really opened */
if (can_socket_ < 0)
@@ -370,17 +370,18 @@ canfd_frame can_bus_dev_t::read()
is_running_ = false;
}
- nbytes = ::read(can_socket_, &canfd_frame, CANFD_MTU);
+ nbytes = ::read(can_socket_, &cfd, CANFD_MTU);
/* if we did not fit into CAN sized messages then stop_reading. */
if (nbytes != CANFD_MTU && nbytes != CAN_MTU)
+ {
if (errno == ENETDOWN)
ERROR(binder_interface, "read: %s CAN device down", device_name_);
- ERROR(binder_interface, "read: Error reading CAN bus");
- ::memset(&canfd_frame, 0, sizeof(canfd_frame));
- stop_reading();
+ ERROR(binder_interface, "read: Incomplete CAN(FD) frame");
+ ::memset(&cfd, 0, sizeof(cfd));
+ }
- return canfd_frame;
+ return cfd;
}
void can_bus_dev_t::start_reading(can_bus_t& can_bus)
diff --git a/src/can-message.cpp b/src/can-message.cpp
index a95722e..e273248 100644
--- a/src/can-message.cpp
+++ b/src/can-message.cpp
@@ -186,7 +186,7 @@ void can_message_t::convert_from_canfd_frame(const struct canfd_frame& frame)
data_.reserve(dlen);
set_data(frame.data, dlen);
- DEBUG(binder_interface, "convert_from_canfd_frame: Found id: %d, format: %d, length: %d, data %d%d%d%d%d%d%d%d", id_, format_, length_,
+ DEBUG(binder_interface, "convert_from_canfd_frame: Found id: %X, format: %X, length: %X, data %02X%02X%02X%02X%02X%02X%02X%02X", id_, format_, length_,
data_[0], data_[1], data_[2], data_[3], data_[4], data_[5], data_[6], data_[7]);
}