Skip to content

Commit bc4aaee

Browse files
committed
避免cmd文件名重复
1 parent 12188e6 commit bc4aaee

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

SharedTopic.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ depends: []
1717
// clang-format on
1818

1919
#include <cstdint>
20+
#include <cstring>
2021

2122
#include "app_framework.hpp"
2223
#include "libxr_def.hpp"
@@ -47,7 +48,10 @@ class SharedTopic : public LibXR::Application
4748
: uart_(hw.template Find<LibXR::UART>(uart_name)),
4849
server_(buffer_size),
4950
rx_buffer_(new uint8_t[buffer_size], buffer_size),
50-
cmd_file_(LibXR::RamFS::CreateFile("shared_topic", CommandFunc, this))
51+
cmd_name_(new char[sizeof("shared_topic:") + strlen(uart_name)]),
52+
cmd_file_((strcpy(cmd_name_, "shared_topic:"),
53+
strcpy(cmd_name_ + strlen("shared_topic:"), uart_name),
54+
LibXR::RamFS::CreateFile(cmd_name_, CommandFunc, this)))
5155
{
5256
for (auto config : topic_configs)
5357
{
@@ -136,6 +140,8 @@ class SharedTopic : public LibXR::Application
136140

137141
size_t rx_count_ = 0;
138142

143+
char *cmd_name_;
144+
139145
LibXR::RamFS::File cmd_file_;
140146

141147
LibXR::Thread rx_thread_;

0 commit comments

Comments
 (0)