From c15c0be2a84546683631e1ecf0bf88d1f029bb52 Mon Sep 17 00:00:00 2001 From: Patrick Goebel Date: Thu, 17 Nov 2016 06:00:47 -0800 Subject: [PATCH] Close serial port on exit --- ros_arduino_python/nodes/arduino_node.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ros_arduino_python/nodes/arduino_node.py b/ros_arduino_python/nodes/arduino_node.py index 97b9316..e2749a3 100755 --- a/ros_arduino_python/nodes/arduino_node.py +++ b/ros_arduino_python/nodes/arduino_node.py @@ -477,7 +477,7 @@ class ArduinoROS(): rospy.sleep(0.2) # Close the serial port - #self.device.serial_port.close() + self.device.close() if __name__ == '__main__': try: @@ -486,7 +486,9 @@ if __name__ == '__main__': try: myArduino.device.serial_port.close() except: + rospy.logerr("Serial exception trying to close port.") os._exit(0) except SerialException: + rospy.logerr("Serial exception trying to open port.") os._exit(0)