summaryrefslogtreecommitdiffstats
path: root/src/can/can-bus-dev.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-03-13 09:02:45 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2017-03-16 17:14:37 +0100
commit228220efbde99b38ff29a9f58f59ba5c62aedfe6 (patch)
treec5ebe980665eb0ea3fd26dec53c8edabdfa51964 /src/can/can-bus-dev.cpp
parent34d859437e958d31e38bef4c2e696ed35a994234 (diff)
fix: test for opened CAN socket.
Change-Id: If9e3a0511c7ccc703817069a56bd38d7e64ebb09 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src/can/can-bus-dev.cpp')
-rw-r--r--src/can/can-bus-dev.cpp10
1 files changed, 5 insertions, 5 deletions
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_));