From ac79a99b40b0e7f3add2d61e55956cc4c6dd9be2 Mon Sep 17 00:00:00 2001 From: ljuricic <98381369+ljuricic@users.noreply.github.com> Date: Fri, 7 Oct 2022 15:30:35 +0200 Subject: [PATCH] fix unit conversion bug in to_timeval() Signed-off-by: ljuricic <98381369+ljuricic@users.noreply.github.com> --- ros2_socketcan/src/socket_can_common.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ros2_socketcan/src/socket_can_common.cpp b/ros2_socketcan/src/socket_can_common.cpp index f9cede8..603e173 100644 --- a/ros2_socketcan/src/socket_can_common.cpp +++ b/ros2_socketcan/src/socket_can_common.cpp @@ -82,7 +82,7 @@ struct timeval to_timeval(const std::chrono::nanoseconds timeout) noexcept constexpr auto BILLION = 1'000'000'000LL; struct timeval c_timeout; c_timeout.tv_sec = static_cast(count / BILLION); - c_timeout.tv_usec = static_cast((count % BILLION) * 1000LL); + c_timeout.tv_usec = static_cast((count % BILLION) / 1000LL); return c_timeout; }