Added heart beat test for the serial connection which allows unplugging and plugging back in the serial line

This commit is contained in:
Patrick Goebel 2016-04-02 18:53:20 -07:00
parent afad6f10d9
commit 4853533400

View File

@ -214,6 +214,20 @@ class ArduinoROS():
# Start polling the sensors, base controller, and servo controller
while not rospy.is_shutdown():
# Heartbeat test for the serial connection
try:
self.device.serial_port.inWaiting()
except IOError:
rospy.loginfo("Lost serial connection...")
self.device.close()
while True:
try:
self.device.open()
rospy.loginfo("Serial connection re-established.")
break
except:
r.sleep()
for sensor in self.mySensors:
if sensor.rate != 0:
mutex.acquire()