From 228220efbde99b38ff29a9f58f59ba5c62aedfe6 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Mon, 13 Mar 2017 09:02:45 +0100 Subject: fix: test for opened CAN socket. Change-Id: If9e3a0511c7ccc703817069a56bd38d7e64ebb09 Signed-off-by: Romain Forlot --- src/can/can-bus-dev.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/can/can-bus-dev.cpp b/src/can/can-bus-dev.cpp index 3aafff3b..5c8673c8 100644 --- a/src/can/can-bus-dev.cpp +++ b/src/can/can-bus-dev.cpp @@ -100,7 +100,7 @@ int can_bus_dev_t::open() } close(); } - else ERROR(binder_interface, "socket could not be created. Error was : %s", ::strerror(errno)); + else ERROR(binder_interface, "open: socket could not be created. Error was : %s", ::strerror(errno)); return -1; } @@ -117,9 +117,9 @@ can_message_t can_bus_dev_t::read() struct canfd_frame cfd; // Test that socket is really opened - if (can_socket_) + if (!can_socket_) { - ERROR(binder_interface, "read_can: Socket unavailable. Closing thread."); + ERROR(binder_interface, "read: Socket unavailable. Closing thread."); is_running_ = false; } @@ -180,7 +180,7 @@ int can_bus_dev_t::send(can_message_t& can_msg) f = can_msg.convert_to_canfd_frame(); - if(can_socket_.socket()) + if(can_socket_) { nbytes = ::sendto(can_socket_.socket(), &f, sizeof(struct canfd_frame), 0, (struct sockaddr*)&txAddress_, sizeof(txAddress_)); @@ -211,7 +211,7 @@ bool can_bus_dev_t::shims_send(const uint32_t arbitration_id, const uint8_t* dat f.len = size; ::memcpy(f.data, data, size); - if(can_socket_.socket()) + if(can_socket_) { nbytes = ::sendto(can_socket_.socket(), &f, sizeof(struct canfd_frame), 0, (struct sockaddr*)&txAddress_, sizeof(txAddress_)); -- cgit 1.2.3-korg