Skip to content

NMEA sentence validation crashes the node #58

@ndmmdn

Description

@ndmmdn

I have been debugging my ntrip node randomly shutting down for a while and finally noticed that it seems to be when my GPS receiver is sending mangled NMEA sentences (why this is happening is also under investigation.) However, this should not lead to the crashing of the node, rather if the encoding doesn't work, its clearly not a valid NMEA sentence and should be gracefully handled as such.

Associated Traceback:

[ntrip_ros.py-1] [INFO] [1734013184.973379283] [ntrip_client.ntrip_client_node]: Stopping RTCM publisher
[ntrip_ros.py-1] [INFO] [1734013184.973952554] [ntrip_client.ntrip_client_node]: Disconnecting NTRIP client
[ntrip_ros.py-1] [INFO] [1734013184.974459070] [ntrip_client.ntrip_client_node]: Shutting down node
[ntrip_ros.py-1] Traceback (most recent call last):
[ntrip_ros.py-1]   File "/home/angsa/overlay_ws/install/ntrip_client/lib/ntrip_client/ntrip_ros.py", line 7, in <module>
[ntrip_ros.py-1]     exec(compile(f.read(), __file__, 'exec'))
[ntrip_ros.py-1]   File "/home/angsa/overlay_ws/build/ntrip_client/scripts/ntrip_ros.py", line 101, in <module>
[ntrip_ros.py-1]     raise e
[ntrip_ros.py-1]   File "/home/angsa/overlay_ws/build/ntrip_client/scripts/ntrip_ros.py", line 97, in <module>
[ntrip_ros.py-1]     rclpy.spin(node)
[ntrip_ros.py-1]   File "/opt/ros/jazzy/lib/python3.12/site-packages/rclpy/__init__.py", line 244, in spin
[ntrip_ros.py-1]     executor.spin_once()
[ntrip_ros.py-1]   File "/opt/ros/jazzy/lib/python3.12/site-packages/rclpy/executors.py", line 827, in spin_once
[ntrip_ros.py-1]     self._spin_once_impl(timeout_sec)
[ntrip_ros.py-1]   File "/opt/ros/jazzy/lib/python3.12/site-packages/rclpy/executors.py", line 822, in _spin_once_impl
[ntrip_ros.py-1]     raise handler.exception()
[ntrip_ros.py-1]   File "/opt/ros/jazzy/lib/python3.12/site-packages/rclpy/task.py", line 239, in __call__
[ntrip_ros.py-1]     self._handler.send(None)
[ntrip_ros.py-1]   File "/opt/ros/jazzy/lib/python3.12/site-packages/rclpy/executors.py", line 508, in handler
[ntrip_ros.py-1]     await call_coroutine()
[ntrip_ros.py-1]   File "/opt/ros/jazzy/lib/python3.12/site-packages/rclpy/executors.py", line 396, in _execute
[ntrip_ros.py-1]     await await_or_execute(sub.callback, *msg_tuple)
[ntrip_ros.py-1]   File "/opt/ros/jazzy/lib/python3.12/site-packages/rclpy/executors.py", line 111, in await_or_execute
[ntrip_ros.py-1]     return callback(*args)
[ntrip_ros.py-1]            ^^^^^^^^^^^^^^^
[ntrip_ros.py-1]   File "/home/angsa/overlay_ws/build/ntrip_client/scripts/ntrip_ros_base.py", line 119, in subscribe_nmea
[ntrip_ros.py-1]     self._client.send_nmea(nmea.sentence)
[ntrip_ros.py-1]   File "/home/angsa/overlay_ws/build/ntrip_client/src/ntrip_client/ntrip_client.py", line 171, in send_nmea
[ntrip_ros.py-1]     if not self.nmea_parser.is_valid_sentence(sentence):
[ntrip_ros.py-1]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ntrip_ros.py-1]   File "/home/angsa/overlay_ws/build/ntrip_client/src/ntrip_client/nmea_parser.py", line 73, in is_valid_sentence
[ntrip_ros.py-1]     expected_checksum = int(expected_checksum_str, 16)
[ntrip_ros.py-1]                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ntrip_ros.py-1] ValueError: invalid literal for int() with base 16: '\r\n'
[ERROR] [ntrip_ros.py-1]: process has died [pid 9221, exit code 1, cmd '/home/angsa/overlay_ws/install/ntrip_client/lib/ntrip_client/ntrip_ros.py --ros-args -r __node:=ntrip_client_node -r __ns:=/ntrip_client --params-file /tmp/launch_params_3icpdxep'].```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions