LivoxProto1: Device: misc logging, cleanup, bugfix

This commit is contained in:
2025-10-24 01:29:18 -04:00
parent 06c5f4503f
commit 71c2b855ec
+14 -4
View File
@@ -233,6 +233,16 @@ public:
bool success
)
{
if (!success)
{
std::cerr << __func__ << ": Failed to enable point cloud data for "
"device (" << context->device.discoveredDevice.deviceIdentifier
<< ") @(" << context->device.discoveredDevice.ipAddr << ").\n";
context->callOriginalCb(false);
return;
}
context->callOriginalCb(success);
}
};
@@ -1697,7 +1707,8 @@ void Device::enablePcloudDataReq(
{
std::cerr << __func__ << ": Failed to set up point cloud data socket"
<< std::endl;
// Don't fail the command, but log the issue
request->callOriginalCallbackWithFailure();
return;
}
// Send the start sampling command
@@ -1753,7 +1764,7 @@ bool Device::setupPcloudDataSocket()
int fd;
SocketRAII(int socketFd) : fd(socketFd) {}
~SocketRAII() { if (fd >= 0) close(fd); }
void commit() { fd = -1; } // Transfer ownership, prevent close
void release() { fd = -1; } // Release ownership, prevent close
int getFd() const { return fd; }
bool isValid() const { return fd >= 0; }
};
@@ -1799,8 +1810,7 @@ bool Device::setupPcloudDataSocket()
componentThread->getIoService(), socketGuard.getFd());
pcloudDataFd = socketGuard.getFd();
// Transfer ownership, prevent auto-close
socketGuard.commit();
socketGuard.release();
return true;
}