Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rosserial_python] Use rospy.on_shutdown in SerialClient shutdown #594

Open
wants to merge 1 commit into
base: melodic-devel
Choose a base branch
from

Conversation

708yamaguchi
Copy link

When I use serial_node.py from roslaunch, we cannot kill serial_node.py by Ctrl-c.

This is because serial_node.py does not catch SystemExit exception caused by sys.exit(0) in txStopRequest.

try:
client = SerialClient(port_name, baud, fix_pyserial_for_test=fix_pyserial_for_test)
client.run()
except KeyboardInterrupt:
break
except SerialException:
sleep(1.0)
continue
except OSError:
sleep(1.0)
continue
except:
rospy.logwarn("Unexpected Error: %s", sys.exc_info()[0])
client.port.close()
sleep(1.0)
continue

In this PR, I used rospy.on_shutdown instead of signal.signal(signal.SIGINT, self.txStopRequest), following 8fb7954 (#508) and #551
This change enables to kill serial_node.py by Ctrl-c.

Thank you very much for your help, @sktometometo

@Hommus
Copy link

Hommus commented Feb 24, 2023

Thanks for this PR @708yamaguchi!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants