From 5316caa0fe3696959019f6205c5b568c1da15cb8 Mon Sep 17 00:00:00 2001 From: Hal Jarrett Date: Fri, 5 Oct 2018 10:09:27 -0400 Subject: [PATCH] Allow driver to recover on USB disconnect / reconnect --- src/kangaroo_driver.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/kangaroo_driver.cpp b/src/kangaroo_driver.cpp index cab738d..b966103 100644 --- a/src/kangaroo_driver.cpp +++ b/src/kangaroo_driver.cpp @@ -319,6 +319,8 @@ bool kangaroo::send_get_request(unsigned char address, char channel, unsigned ch if (0 > write(fd, buffer, num_of_bytes)) { ROS_ERROR("Failed to write to serial."); + close(); + fd = -1; return false; } @@ -510,6 +512,7 @@ void kangaroo::handle_errors(unsigned char address, int error_code) ROS_ERROR("The given parameter is unknown."); break; case 6: + send_start_signals(address); ROS_ERROR("Serial timeout occurred."); break; default: