mirror of
https://github.com/YikeStone/ros_arduino_bridge.git
synced 2025-08-03 19:24:09 +05:30
Added heart beat test for the serial connection which allows unplugging and plugging back in the serial line
This commit is contained in:
parent
afad6f10d9
commit
4853533400
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user