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

Rewrite nmea_socket_driver to use serversocket #92

Merged
merged 2 commits into from Feb 1, 2020
Merged

Rewrite nmea_socket_driver to use serversocket #92

merged 2 commits into from Feb 1, 2020

Conversation

rgov
Copy link
Contributor

@rgov rgov commented Jan 19, 2020

This is deviating a little from #90. I recommend testing on Windows since select() behaves slightly differently there, and on Python 2.7 if that is still supported.

Rather than using low level socket APIs, this uses the Python SocketServer module. This simplifies the code by several lines and makes it easier to support TCP packets in the future.

The buffer_size parameter is no longer necessary because this is an internal detail of UDPServer.

Copy link
Collaborator

@evenator evenator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a much cleaner implementation than the previous socket server. I haven't had a chance to test it completely, but I have a few preliminary comments.

Regarding Windows--this package doesn't officially support Windows, and I've never tested it on Windows. It's pure Python, so presumably it's one of the easier ROS 1 packages to use in Windows, but I'm not concerned if this breaks Windows support, since any Windows support was luck in the first place.

We do need to maintain Python 2.7 support in ROS Melodic unfortunately.

src/libnmea_navsat_driver/nodes/nmea_socket_driver.py Outdated Show resolved Hide resolved
src/libnmea_navsat_driver/nodes/nmea_socket_driver.py Outdated Show resolved Hide resolved
src/libnmea_navsat_driver/nodes/nmea_socket_driver.py Outdated Show resolved Hide resolved
src/libnmea_navsat_driver/nodes/nmea_socket_driver.py Outdated Show resolved Hide resolved
src/libnmea_navsat_driver/nodes/nmea_socket_driver.py Outdated Show resolved Hide resolved
@rgov rgov requested a review from evenator January 20, 2020 16:00
@evenator evenator assigned evenator and unassigned rgov Jan 20, 2020
Copy link
Collaborator

@evenator evenator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I approved with one minor comment. As soon as I have a chance to test this, I'll merge it in. Thanks!

"```\n" +
repr(line) + "\n\n" +
traceback.format_exc() +
"```")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest you use format() here, i.e.:

rospy.logwarn("ValueError, likely due to missing fields in the NMEA "
              "message. Please report this issue at "
              "https://github.com/ros-drivers/nmea_navsat_driver"
              ", including the following:\n\n```\n{0}\n\n{1}```"
              .format(repr(line), traceback.format_exc()))

@rgov
Copy link
Contributor Author

rgov commented Jan 30, 2020

Hi @evenator, did you have time to give this a shake?

Copy link
Collaborator

@evenator evenator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I took so long to test this out.

I've tested it, and there don't seem to be any regressions. I'll merge this to master, and I think it can be included in the next release to existing supported ROS distributions because there are no breaking changes to the API. Thanks for your contribution!

@evenator evenator merged commit 062f379 into ros-drivers:master Feb 1, 2020
@rgov
Copy link
Contributor Author

rgov commented Feb 14, 2020

@evenator Do you know when the next release will happen (or happened)?

evenator pushed a commit to evenator/nmea_navsat_driver that referenced this pull request Feb 23, 2020
Use Python's SocketServer rather than low level socket APIs. This simplifies code and makes it easier to add TCP support in the future. The buffer_size parameter is no longer necessary because this is an internal detail of UDPServer.
evenator pushed a commit to evenator/nmea_navsat_driver that referenced this pull request Feb 23, 2020
Use Python's SocketServer rather than low level socket APIs. This simplifies code and makes it easier to add TCP support in the future. The buffer_size parameter is no longer necessary because this is an internal detail of UDPServer.
@evenator
Copy link
Collaborator

evenator commented Feb 24, 2020

@rgov I backported this PR (and several others) to ROS Melodic in #95 and just opened PR ros/rosdistro#23858 to make a new release.

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

Successfully merging this pull request may close these issues.

None yet

2 participants