Skip to content

Commit

Permalink
Merge pull request #4 from DeepX-inc/bugfix/fixed-spam-CU-86eq3zgda
Browse files Browse the repository at this point in the history
Bugfix spam cu 86eq3zgda
  • Loading branch information
paulo-deepx authored Oct 7, 2024
2 parents 936bd4a + 42e72df commit bcd748b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
15 changes: 13 additions & 2 deletions livox_ros2_driver/livox_ros2_driver/lds_hub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <string.h>
#include <memory>
#include <thread>
#include <unordered_set>

#include "rapidjson/document.h"
#include "rapidjson/filereadstream.h"
Expand Down Expand Up @@ -157,10 +158,16 @@ void LdsHub::OnHubDataCb(uint8_t hub_handle, LivoxEthPacket *data,
}

void LdsHub::OnDeviceBroadcast(const BroadcastDeviceInfo *info) {
// Store warning status per broadcast code to avoid showing the same warning
static std::unordered_set<std::string> whitelist_warning_shown_map;

if (info == NULL) {
return;
}

// Convert broadcast code to string
std::string broadcast_code(info->broadcast_code);

if (info->dev_type != kDeviceTypeHub) {
printf("It's not a hub : %s\n", info->broadcast_code);
return;
Expand All @@ -171,8 +178,12 @@ void LdsHub::OnDeviceBroadcast(const BroadcastDeviceInfo *info) {
info->broadcast_code);
} else {
if (!g_lds_hub->IsBroadcastCodeExistInWhitelist(info->broadcast_code)) {
printf("Not in the whitelist, please add %s to if want to connect!\n",
info->broadcast_code);
// Check if the warning for this broadcast code was already shown
if (whitelist_warning_shown_map.find(broadcast_code) == whitelist_warning_shown_map.end()) {
printf("Not in the whitelist, please add %s to if want to connect!\n",
info->broadcast_code);
whitelist_warning_shown_map.insert(broadcast_code);
}
return;
}
}
Expand Down
15 changes: 13 additions & 2 deletions livox_ros2_driver/livox_ros2_driver/lds_lidar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <memory>
#include <mutex>
#include <thread>
#include <unordered_set>

#include "rapidjson/document.h"
#include "rapidjson/filereadstream.h"
Expand Down Expand Up @@ -172,10 +173,16 @@ void LdsLidar::OnLidarDataCb(uint8_t handle, LivoxEthPacket *data,
}

void LdsLidar::OnDeviceBroadcast(const BroadcastDeviceInfo *info) {
// Store warning status per broadcast code to avoid showing the same warning
static std::unordered_set<std::string> whitelist_warning_shown_map;

if (info == nullptr) {
return;
}

// Convert broadcast code to string
std::string broadcast_code(info->broadcast_code);

if (info->dev_type == kDeviceTypeHub) {
printf("In lidar mode, couldn't connect a hub : %s\n",
info->broadcast_code);
Expand All @@ -187,8 +194,12 @@ void LdsLidar::OnDeviceBroadcast(const BroadcastDeviceInfo *info) {
info->broadcast_code);
} else {
if (!g_lds_ldiar->IsBroadcastCodeExistInWhitelist(info->broadcast_code)) {
printf("Not in the whitelist, please add %s to if want to connect!\n",
info->broadcast_code);
// Check if the warning for this broadcast code was already shown
if (whitelist_warning_shown_map.find(broadcast_code) == whitelist_warning_shown_map.end()) {
printf("Not in the whitelist, please add %s to if want to connect!\n",
info->broadcast_code);
whitelist_warning_shown_map.insert(broadcast_code);
}
return;
}
}
Expand Down

0 comments on commit bcd748b

Please sign in to comment.