1 Commits

Author SHA1 Message Date
Livox-louie 14c533dd71 fix ROS2 Humble build error 2024-12-17 21:11:06 +08:00
10 changed files with 34 additions and 75 deletions
+1 -1
View File
@@ -233,5 +233,5 @@ Here is the example:
# 5 Support # 5 Support
You can get support from Livox with the following methods: You can get support from Livox with the following methods:
* Send email to cs@livoxtech.com with a clear description of your problem and your setup * Send email to dev@livoxtech.com with a clear description of your problem and your setup
* Github Issues * Github Issues
+1 -1
View File
@@ -234,5 +234,5 @@ char broadcast_code_list[kMaxLidarCount][kBroadcastCodeSize] = {
# 5 支持 # 5 支持
你可以通过以下方式获取 Livox 的技术支持 : 你可以通过以下方式获取 Livox 的技术支持 :
* 发送邮件到 cs@livoxtech.com 描述清楚问题和使用场景 * 发送邮件到 dev@livoxtech.com 描述清楚问题和使用场景
* Github Issues * Github Issues
+1 -1
View File
@@ -41,7 +41,7 @@
#define HAVE_KQUEUE 1 #define HAVE_KQUEUE 1
#else #else
#include <sys/poll.h> #include <sys/poll.h>
#define HAVE_POLL 1 #define HAVE POLL 1
#endif #endif
#endif // CONFIG_H_ #endif // CONFIG_H_
+1 -1
View File
@@ -643,7 +643,7 @@ typedef struct {
uint8_t month; uint8_t month;
uint8_t day; uint8_t day;
uint8_t hour; uint8_t hour;
uint32_t microsecond; uint32_t mircrosecond;
} LidarSetUtcSyncTimeRequest; } LidarSetUtcSyncTimeRequest;
/** /**
@@ -83,27 +83,22 @@ bool MultipleIOKqueue::PollSetAdd(PollFd poll_fd) {
bool MultipleIOKqueue::PollSetRemove(PollFd poll_fd) { bool MultipleIOKqueue::PollSetRemove(PollFd poll_fd) {
int fd = poll_fd.fd; int fd = poll_fd.fd;
bool result = true;
if (descriptors_.find(fd) != descriptors_.end()) { if (descriptors_.find(fd) != descriptors_.end()) {
do { if (descriptors_[fd].event & READBLE_EVENT) {
if (descriptors_[fd].event & READBLE_EVENT) { EV_SET(&kevent_, fd, EVFILT_READ, EV_DELETE, 0, 0, NULL);
EV_SET(&kevent_, fd, EVFILT_READ, EV_DELETE, 0, 0, NULL); if (kevent(kqueue_fd_, &kevent_, 1, nullptr, 0, nullptr) == -1) {
if (kevent(kqueue_fd_, &kevent_, 1, nullptr, 0, nullptr) == -1) { return false;
result = false;
break;
}
} }
if (descriptors_[fd].event & WRITABLE_EVENT) { }
EV_SET(&kevent_, fd, EVFILT_WRITE, EV_DELETE, 0, 0, NULL); if (descriptors_[fd].event & WRITABLE_EVENT) {
if (kevent(kqueue_fd_, &kevent_, 1, nullptr, 0, nullptr) == -1) { EV_SET(&kevent_, fd, EVFILT_WRITE, EV_DELETE, 0, 0, NULL);
result = false; if (kevent(kqueue_fd_, &kevent_, 1, nullptr, 0, nullptr) == -1) {
break; return false;
}
} }
} while(0); }
descriptors_.erase(fd); descriptors_.erase(fd);
} }
return result; return true;
} }
void MultipleIOKqueue::Poll(int time_out) { void MultipleIOKqueue::Poll(int time_out) {
@@ -93,10 +93,10 @@ void MultipleIOPoll:: Poll(int time_out) {
for (int i = 0; i < pollset_num_; i++) { for (int i = 0; i < pollset_num_; i++) {
FdEvent fd_event = NONE_EVENT; FdEvent fd_event = NONE_EVENT;
if (pollset_[i].revents & POLLIN) { if (pollset_[i].revents & POLLIN) {
fd_event |= READBLE_EVENT; fd_event = | READBLE_EVENT;
} }
if (pollset_[i].revents & POLLOUT) { if (pollset_[i].revents & POLLOUT) {
fd_event |= WRITABLE_EVENT; fd_event = | WRITABLE_EVENT;
} }
int fd = pollset_[i].fd; int fd = pollset_[i].fd;
if (descriptors_.find(fd) != descriptors_.end()) { if (descriptors_.find(fd) != descriptors_.end()) {
+1
View File
@@ -26,6 +26,7 @@
#define LIVOX_THREAD_BASE_H_ #define LIVOX_THREAD_BASE_H_
#include <atomic> #include <atomic>
#include <thread> #include <thread>
#include <memory>
#include "noncopyable.h" #include "noncopyable.h"
namespace livox { namespace livox {
+15 -28
View File
@@ -67,43 +67,30 @@ bool WakeUpPipe::PipeDestroy() {
} }
bool WakeUpPipe::PipeCreate() { bool WakeUpPipe::PipeCreate() {
bool status = false;
//in filedes[0] //in filedes[0]
//out filedes[1] //out filedes[1]
int filedes[2]= {}; int filedes[2];
if (pipe(filedes) == -1) { if (pipe(filedes) == -1) {
return false; return false;
} }
do {
int flags = 0;
if ((flags = fcntl(filedes[0], F_GETFD)) == -1) {
break;
}
flags |= FD_CLOEXEC; int flags = 0;
if (fcntl(filedes[0], F_SETFD, flags) == -1) { if ((flags = fcntl(filedes[0], F_GETFL|O_NONBLOCK)) == -1) {
break; return false;
} }
flags = 0; flags |= FD_CLOEXEC;
if ((flags = fcntl(filedes[1], F_GETFD)) == -1) { if (fcntl(filedes[0], F_SETFL, flags) == -1) {
break; return false;
} }
flags |= FD_CLOEXEC; flags = 0;
if (fcntl(filedes[1], F_SETFD, flags) == -1) { if ((flags = fcntl(filedes[1], F_GETFD)) == -1) {
break; return false;
} }
status = true;
} while(0);
if (!status) { flags |= FD_CLOEXEC;
if (filedes[0] > 0) { if (fcntl(filedes[1], F_SETFD, flags) == -1) {
close(filedes[0]);
}
if (filedes[1] > 0) {
close(filedes[1]);
}
return false; return false;
} }
pipe_out_ = filedes[0]; pipe_out_ = filedes[0];
@@ -209,7 +209,7 @@ bool ParseRmcTime(const char* rmc, uint16_t rmc_len, LidarSetUtcSyncTimeRequest*
} }
utc_time_req->hour = hour; utc_time_req->hour = hour;
utc_time_req->microsecond = (minute * 60 * 1000 + second * 1000) * 1000; utc_time_req->mircrosecond = (minute * 60 * 1000 + second * 1000) * 1000;
return true; return true;
} }
-24
View File
@@ -160,18 +160,6 @@ void DeviceManager::HubLidarInfomationCallback(livox_status status, uint8_t, Hub
if (connected_cb_) { if (connected_cb_) {
connected_cb_(&(devices_[kHubDefaultHandle].info), kEventHubConnectionChange); connected_cb_(&(devices_[kHubDefaultHandle].info), kEventHubConnectionChange);
} }
} else if (status == kStatusTimeout) {
LOG_WARN("Query lidars information Timeout.");
if (IsDeviceConnected(kHubDefaultHandle)) {
LOG_INFO("Retry to query lidars information.");
command_handler().SendCommand(kHubDefaultHandle,
kCommandSetHub,
kCommandIDHubQueryLidarInformation,
NULL,
0,
MakeCommandCallback<DeviceManager, HubQueryLidarInformationResponse>(
this, &DeviceManager::HubLidarInfomationCallback));
}
} else { } else {
LOG_ERROR("Failed to query lidars information connected to hub."); LOG_ERROR("Failed to query lidars information connected to hub.");
} }
@@ -190,18 +178,6 @@ void DeviceManager::QueryDeviceInformationCallback(livox_status status, uint8_t
if (connected_cb_) { if (connected_cb_) {
connected_cb_(&devices_[handle].info, kEventConnect); connected_cb_(&devices_[handle].info, kEventConnect);
} }
} else if (status == kStatusTimeout) {
LOG_WARN("Query lidar information Timeout.");
if (IsDeviceConnected(handle)) {
LOG_INFO("Retry to query lidar information.");
command_handler().SendCommand(handle,
kCommandSetGeneral,
kCommandIDGeneralDeviceInfo,
NULL,
0,
MakeCommandCallback<DeviceManager, DeviceInformationResponse>(
this, &DeviceManager::QueryDeviceInformationCallback));
}
} else { } else {
LOG_ERROR("Failed to query lidar information."); LOG_ERROR("Failed to query lidar information.");
} }