From 2168e7f383949cb9d89fa579ea312620d3a0ad53 Mon Sep 17 00:00:00 2001 From: Kamiccolo Date: Tue, 16 Mar 2021 13:21:58 +0200 Subject: [PATCH 1/5] fix: typo in definitions and command_impl mircrosecond -> microsecond --- sdk_core/include/livox_def.h | 2 +- sdk_core/src/command_handler/command_impl.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk_core/include/livox_def.h b/sdk_core/include/livox_def.h index cd1582a..d627db3 100644 --- a/sdk_core/include/livox_def.h +++ b/sdk_core/include/livox_def.h @@ -643,7 +643,7 @@ typedef struct { uint8_t month; uint8_t day; uint8_t hour; - uint32_t mircrosecond; + uint32_t microsecond; } LidarSetUtcSyncTimeRequest; /** diff --git a/sdk_core/src/command_handler/command_impl.cpp b/sdk_core/src/command_handler/command_impl.cpp index 486b4ae..77d6876 100644 --- a/sdk_core/src/command_handler/command_impl.cpp +++ b/sdk_core/src/command_handler/command_impl.cpp @@ -209,7 +209,7 @@ bool ParseRmcTime(const char* rmc, uint16_t rmc_len, LidarSetUtcSyncTimeRequest* } utc_time_req->hour = hour; - utc_time_req->mircrosecond = (minute * 60 * 1000 + second * 1000) * 1000; + utc_time_req->microsecond = (minute * 60 * 1000 + second * 1000) * 1000; return true; } -- 2.52.0 From 53872851d208adfa4bf31e5f0630479aacbdd989 Mon Sep 17 00:00:00 2001 From: Livox-SDK Date: Tue, 20 Apr 2021 12:25:48 +0800 Subject: [PATCH 2/5] cancle heartbeat timeout --- .../src/command_handler/command_channel.cpp | 6 +-- sdk_core/src/device_discovery.cpp | 51 ++++++++++++++++++- sdk_core/src/device_discovery.h | 2 + 3 files changed, 53 insertions(+), 6 deletions(-) diff --git a/sdk_core/src/command_handler/command_channel.cpp b/sdk_core/src/command_handler/command_channel.cpp index 913aaa9..5cd9103 100644 --- a/sdk_core/src/command_handler/command_channel.cpp +++ b/sdk_core/src/command_handler/command_channel.cpp @@ -146,11 +146,7 @@ void CommandChannel::OnTimer(TimePoint now) { } } - if (now - last_heartbeat_ > std::chrono::seconds(3)) { - DeviceDisconnect(handle_); - } else { - HeartBeat(now); - } + HeartBeat(now); } void CommandChannel::Uninit() { diff --git a/sdk_core/src/device_discovery.cpp b/sdk_core/src/device_discovery.cpp index b3b70f1..1cae0f7 100644 --- a/sdk_core/src/device_discovery.cpp +++ b/sdk_core/src/device_discovery.cpp @@ -30,6 +30,7 @@ #include "base/logging.h" #include "base/network/network_util.h" #include "command_handler/command_impl.h" +#include "command_handler/command_handler.h" #include "device_manager.h" #include "livox_def.h" @@ -139,6 +140,52 @@ void DeviceDiscovery::Uninit() { } } + +void DeviceDiscovery::ReConnectDevice(const DeviceInfo& lidar_info, struct sockaddr *addr) { + HandshakeRequest handshake_req; + uint32_t local_ip = 0; + if (util::FindLocalIp(*(struct sockaddr_in*)addr, local_ip) == false) { + LOG_INFO("LocalIp and DeviceIp are not in same subnet"); + LOG_INFO("LocalIP: {}", inet_ntoa(*(struct in_addr *)&local_ip)); + LOG_INFO("DeviceIP: {}", inet_ntoa(((struct sockaddr_in *)addr)->sin_addr)); + return; + } + LOG_INFO("ReConnect Device"); + LOG_INFO("LocalIP: {}", inet_ntoa(*(struct in_addr *)&local_ip)); + LOG_INFO("DeviceIP: {}", inet_ntoa(((struct sockaddr_in *)addr)->sin_addr)); + LOG_INFO("Command Port: {}", lidar_info.cmd_port); + LOG_INFO("Data Port: {}", lidar_info.data_port); + handshake_req.ip_addr = local_ip; + handshake_req.cmd_port = lidar_info.cmd_port; + handshake_req.data_port = lidar_info.data_port; + + command_handler().SendCommand(lidar_info.handle, + kCommandSetGeneral, + kCommandIDGeneralHandshake, + (uint8_t*)&handshake_req, + sizeof(HandshakeRequest), + MakeCommandCallback( + this, &DeviceDiscovery::OnHandshakeCallback)); +} + +void DeviceDiscovery::OnHandshakeCallback(livox_status status, uint8_t handle, uint8_t) { + if (status != kStatusSuccess) { + LOG_WARN("On HandshakeCallback status: {}", status); + return; + } + DeviceInfo lidar_info; + bool found = device_manager().FindDevice(handle, lidar_info); + if (!found) { + return; + } + + if (device_manager().device_mode() == kDeviceModeHub) { + device_manager().UpdateDevices(lidar_info, kEventHubConnectionChange); + } else { + device_manager().UpdateDevices(lidar_info, kEventConnect); + } +} + void DeviceDiscovery::OnBroadcast(const CommPacket &packet, struct sockaddr *addr) { if (packet.data == NULL) { return; @@ -161,9 +208,11 @@ void DeviceDiscovery::OnBroadcast(const CommPacket &packet, struct sockaddr *ad if (!found) { LOG_INFO("Broadcast code : {} not add to connect", broadcast_code); + return; } - if (!found || device_manager().IsDeviceConnected(lidar_info.handle)) { + if (device_manager().IsDeviceConnected(lidar_info.handle)) { + ReConnectDevice(lidar_info, addr); return; } diff --git a/sdk_core/src/device_discovery.h b/sdk_core/src/device_discovery.h index f0942b1..1045125 100644 --- a/sdk_core/src/device_discovery.h +++ b/sdk_core/src/device_discovery.h @@ -71,7 +71,9 @@ class DeviceDiscovery : public noncopyable, IOLoop::IOLoopDelegate { void OnTimer(TimePoint now); private: + void ReConnectDevice(const DeviceInfo& lidar_info, struct sockaddr *addr); void OnBroadcast(const CommPacket &packet, struct sockaddr *addr); + void OnHandshakeCallback(livox_status status, uint8_t handle, uint8_t); private: /** broadcast listening port number. */ -- 2.52.0 From 14bf8488fe9b385e2b00dd921b3792c7d48beb9b Mon Sep 17 00:00:00 2001 From: livox Date: Wed, 26 May 2021 17:13:00 +0800 Subject: [PATCH 3/5] Update README.md update support email to cs@livoxtech.com --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1293306..1409cb7 100644 --- a/README.md +++ b/README.md @@ -233,5 +233,5 @@ Here is the example: # 5 Support You can get support from Livox with the following methods: -* Send email to dev@livoxtech.com with a clear description of your problem and your setup +* Send email to cs@livoxtech.com with a clear description of your problem and your setup * Github Issues -- 2.52.0 From d7417a39e9ffcd4b0c09aee473af89bc911a79a9 Mon Sep 17 00:00:00 2001 From: livox Date: Tue, 1 Jun 2021 10:38:47 +0800 Subject: [PATCH 4/5] Update README_CN.md --- README_CN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README_CN.md b/README_CN.md index c040ea8..b8e30c1 100644 --- a/README_CN.md +++ b/README_CN.md @@ -234,5 +234,5 @@ char broadcast_code_list[kMaxLidarCount][kBroadcastCodeSize] = { # 5 支持 你可以通过以下方式获取 Livox 的技术支持 : -* 发送邮件到 dev@livoxtech.com 描述清楚问题和使用场景 +* 发送邮件到 cs@livoxtech.com 描述清楚问题和使用场景 * Github Issues -- 2.52.0 From 9306596a2bf15c1343bc023b497465ed0a32909d Mon Sep 17 00:00:00 2001 From: livox Date: Mon, 6 Sep 2021 10:52:21 +0800 Subject: [PATCH 5/5] fix: wakeup pipe create failed --- .../src/base/wake_up/unix/wake_up_pipe.cpp | 43 ++++++++++++------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/sdk_core/src/base/wake_up/unix/wake_up_pipe.cpp b/sdk_core/src/base/wake_up/unix/wake_up_pipe.cpp index 0e58c4c..b15e8e2 100644 --- a/sdk_core/src/base/wake_up/unix/wake_up_pipe.cpp +++ b/sdk_core/src/base/wake_up/unix/wake_up_pipe.cpp @@ -67,30 +67,43 @@ bool WakeUpPipe::PipeDestroy() { } bool WakeUpPipe::PipeCreate() { + bool status = false; //in filedes[0] //out filedes[1] - int filedes[2]; + int filedes[2]= {}; if (pipe(filedes) == -1) { return false; } + do { + int flags = 0; + if ((flags = fcntl(filedes[0], F_GETFD)) == -1) { + break; + } - int flags = 0; - if ((flags = fcntl(filedes[0], F_GETFL|O_NONBLOCK)) == -1) { - return false; - } + flags |= FD_CLOEXEC; + if (fcntl(filedes[0], F_SETFD, flags) == -1) { + break; + } - flags |= FD_CLOEXEC; - if (fcntl(filedes[0], F_SETFL, flags) == -1) { - return false; - } + flags = 0; + if ((flags = fcntl(filedes[1], F_GETFD)) == -1) { + break; + } - flags = 0; - if ((flags = fcntl(filedes[1], F_GETFD)) == -1) { - return false; - } + flags |= FD_CLOEXEC; + if (fcntl(filedes[1], F_SETFD, flags) == -1) { + break; + } + status = true; + } while(0); - flags |= FD_CLOEXEC; - if (fcntl(filedes[1], F_SETFD, flags) == -1) { + if (!status) { + if (filedes[0] > 0) { + close(filedes[0]); + } + if (filedes[1] > 0) { + close(filedes[1]); + } return false; } pipe_out_ = filedes[0]; -- 2.52.0