From 39afd72e6e756ca1295b36a35658446c129b59f2 Mon Sep 17 00:00:00 2001 From: Tristan Schnell Date: Thu, 19 Sep 2019 13:48:18 +0200 Subject: [PATCH] Added exception for incorrectly parsed messages. --- ur_rtde_driver/include/ur_rtde_driver/comm/bin_parser.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ur_rtde_driver/include/ur_rtde_driver/comm/bin_parser.h b/ur_rtde_driver/include/ur_rtde_driver/comm/bin_parser.h index 5dd549b..44a3d0f 100644 --- a/ur_rtde_driver/include/ur_rtde_driver/comm/bin_parser.h +++ b/ur_rtde_driver/include/ur_rtde_driver/comm/bin_parser.h @@ -31,6 +31,7 @@ #include #include "ur_rtde_driver/log.h" #include "ur_rtde_driver/types.h" +#include "ur_rtde_driver/exceptions.h" namespace ur_driver { @@ -93,7 +94,10 @@ public: template T peek() { - assert(buf_pos_ + sizeof(T) <= buf_end_); + if (buf_pos_ + sizeof(T) > buf_end_) + throw UrException("Could not parse received package. This can occur if the driver is started while the robot is " + "booting - please restart the driver once the robot has finished booting. " + "If the problem persists after the robot has booted, please contact the package maintainer."); T val; std::memcpy(&val, buf_pos_, sizeof(T)); return decode(val);