-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Length of size limited string is not checked
https://github.com/ros2/rclcpp/issues/1827 Signed-off-by: Tomoya Fujita <[email protected]>
- Loading branch information
1 parent
9290736
commit fabd65b
Showing
5 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
string<=10 size_limited_string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <chrono> | ||
#include <memory> | ||
|
||
using namespace std::chrono_literals; | ||
|
||
#include "rclcpp/rclcpp.hpp" | ||
#include "prover_interfaces/msg/string_length_test.hpp" | ||
|
||
class TestPublisher : public rclcpp::Node | ||
{ | ||
public: | ||
TestPublisher() | ||
: Node("string_length_test_publisher") | ||
{ | ||
publisher_ = this->create_publisher<prover_interfaces::msg::StringLengthTest>("oversized", 10); | ||
timer_ = this->create_wall_timer( | ||
1s, std::bind(&TestPublisher::timer_callback, this)); // 1kHz | ||
} | ||
|
||
private: | ||
void timer_callback() | ||
{ | ||
auto message = prover_interfaces::msg::StringLengthTest(); | ||
message.size_limited_string.resize(11, 'x'); | ||
publisher_->publish(message); | ||
} | ||
rclcpp::TimerBase::SharedPtr timer_; | ||
rclcpp::Publisher<prover_interfaces::msg::StringLengthTest>::SharedPtr publisher_; | ||
}; | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
rclcpp::init(argc, argv); | ||
std::shared_ptr<TestPublisher> pub = std::make_shared<TestPublisher>(); | ||
rclcpp::spin(pub); | ||
rclcpp::shutdown(); | ||
return 0; | ||
} |