squirrel-project / squirrel_driver

0 stars 14 forks source link

No safeguards against reading/writing from different functions to serial port at the same time #142

Closed bajo closed 7 years ago

bajo commented 7 years ago

In https://github.com/squirrel-project/squirrel_driver/blob/indigo_dev/squirrel_interaction/src/squirrel_interaction/board/serial_api.py multiple functions (get_position, move_to, set_mouth_led_colors, ...) access the serial port. On of them is constantly called to update the joint_states of the robot. Calling any of the available commands to do something else (eg. move neck, camera, head, door, etc.) can lead to the node dying with:

Traceback (most recent call last):
  File "/u/bajo/catkin_ws/src/squirrel_driver/squirrel_interaction/src/squirrel_interaction/board/board.py", line 119, in <module>
    controller.run()
  File "/u/bajo/catkin_ws/src/squirrel_driver/squirrel_interaction/src/squirrel_interaction/board/board.py", line 63, in run
    joint_state_msg.position = [radians(self._motor.get_position("head")), radians(self._motor.get_position("neck")), radians(self._motor.get_position("camera")), radians(self._motor.get_position("door"))]
  File "/u/bajo/catkin_ws/src/squirrel_driver/squirrel_interaction/src/squirrel_interaction/board/serial_api.py", line 72, in get_position
    response.extend(self.serial.read(7))
  File "/usr/local/lib/python2.7/dist-packages/serial/serialposix.py", line 501, in read
    'device reports readiness to read but returned no data '
serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected or multiple access on port?)
bajo commented 7 years ago

@ipa-nhg @mzillich I have a fix for this on the robot. Will send pull request later today.

bajo commented 7 years ago

Fixed by PR #146