diff --git a/commonLibs/livoxProto1/core.cpp b/commonLibs/livoxProto1/core.cpp index 7b9b21e..1bbebd0 100644 --- a/commonLibs/livoxProto1/core.cpp +++ b/commonLibs/livoxProto1/core.cpp @@ -129,7 +129,7 @@ public: void DeviceManager::getOrCreateDeviceReq( const std::string &deviceIdentifier, const std::shared_ptr& componentThread, - int handshakeTimeoutMs, int retryDelayMs, + int commandTimeoutMs, int retryDelayMs, const std::string& smoIp, uint8_t smoSubnetNbits, uint16_t dataPort, uint16_t cmdPort, uint16_t imuPort, smo::Callback callback) @@ -163,7 +163,7 @@ void DeviceManager::getOrCreateDeviceReq( // Device doesn't exist, create a new one but don't add it to collection yet auto newDevice = std::make_shared( deviceIdentifier, componentThread, - handshakeTimeoutMs, retryDelayMs, + commandTimeoutMs, retryDelayMs, smoIp, smoSubnetNbits, dataPort, cmdPort, imuPort); diff --git a/commonLibs/livoxProto1/core.h b/commonLibs/livoxProto1/core.h index ab6c052..4ddddde 100644 --- a/commonLibs/livoxProto1/core.h +++ b/commonLibs/livoxProto1/core.h @@ -26,7 +26,7 @@ public: void getOrCreateDeviceReq( const std::string &deviceIdentifier, const std::shared_ptr& componentThread, - int handshakeTimeoutMs, int retryDelayMs, + int commandTimeoutMs, int retryDelayMs, const std::string& smoIp, uint8_t smoSubnetNbits, uint16_t dataPort, uint16_t cmdPort, uint16_t imuPort, smo::Callback callback); diff --git a/commonLibs/livoxProto1/device.cpp b/commonLibs/livoxProto1/device.cpp index 0e92464..05c5a9a 100644 --- a/commonLibs/livoxProto1/device.cpp +++ b/commonLibs/livoxProto1/device.cpp @@ -90,7 +90,7 @@ std::string DiscoveredDevice::getDeviceTypeName(void) const Device::Device(const std::string &deviceIdentifier, const std::shared_ptr& componentThread, - int handshakeTimeoutMs, int retryDelayMs, + int commandTimeoutMs, int retryDelayMs, const std::string& smoIp, uint8_t smoSubnetNbits, uint16_t dataPort, uint16_t cmdPort, uint16_t imuPort) : discoveredDevice( @@ -99,7 +99,7 @@ Device::Device(const std::string &deviceIdentifier, ""), nAttachedStimBuffs(0), componentThread(componentThread), -handshakeTimeoutMs(handshakeTimeoutMs), retryDelayMs(retryDelayMs), +commandTimeoutMs(commandTimeoutMs), retryDelayMs(retryDelayMs), smoIp(smoIp), detectedSmoListeningIp(""), smoSubnetNbits(smoSubnetNbits), dataPort(dataPort), cmdPort(cmdPort), imuPort(imuPort), heartbeatActive(false), @@ -572,7 +572,7 @@ private: * we will consider the handshake to have failed. */ timeoutTimer.expires_from_now( - boost::posix_time::milliseconds(device.handshakeTimeoutMs)); + boost::posix_time::milliseconds(device.commandTimeoutMs)); timeoutTimer.async_wait( std::bind( @@ -651,7 +651,7 @@ private: if (finalTimerFired && finalSocketState == SocketState::SOCKET_STILL_WAITING) { - std::cerr << __func__ << ": Handshake timeout with " + std::cerr << __func__ << ": Command timeout with " << deviceIP << "(" << device.discoveredDevice.deviceIdentifier << ")" << std::endl; @@ -1389,7 +1389,7 @@ protected: { // Setup timeout timer timeoutTimer.expires_from_now( - boost::posix_time::milliseconds(device.handshakeTimeoutMs)); + boost::posix_time::milliseconds(device.commandTimeoutMs)); timeoutTimer.async_wait( std::bind( @@ -1998,7 +1998,7 @@ public: { // Set up timeout timer timeoutTimer.expires_from_now(boost::posix_time::milliseconds( - device.handshakeTimeoutMs)); + device.commandTimeoutMs)); timeoutTimer.async_wait( std::bind(&SetReturnModeReq::setReturnModeReq1_1, this, request, @@ -2245,7 +2245,7 @@ public: { // Set up timeout timer timeoutTimer.expires_from_now(boost::posix_time::milliseconds( - device.handshakeTimeoutMs)); + device.commandTimeoutMs)); timeoutTimer.async_wait( std::bind(&GetReturnModeReq::getReturnModeReq1_1, diff --git a/commonLibs/livoxProto1/device.h b/commonLibs/livoxProto1/device.h index 73b3b78..ea56c24 100644 --- a/commonLibs/livoxProto1/device.h +++ b/commonLibs/livoxProto1/device.h @@ -74,7 +74,7 @@ class Device public: Device(const std::string &deviceIdentifier, const std::shared_ptr& componentThread, - int handshakeTimeoutMs, int retryDelayMs, + int commandTimeoutMs, int retryDelayMs, const std::string& smoIp, uint8_t smoSubnetNbits, uint16_t dataPort, uint16_t cmdPort, uint16_t imuPort); ~Device(); @@ -152,7 +152,7 @@ public: // Configuration std::shared_ptr componentThread; - int handshakeTimeoutMs, retryDelayMs; + int commandTimeoutMs, retryDelayMs; std::string smoIp; std::string detectedSmoListeningIp; uint8_t smoSubnetNbits; diff --git a/commonLibs/livoxProto1/livoxProto1.cpp b/commonLibs/livoxProto1/livoxProto1.cpp index dd01338..4656441 100644 --- a/commonLibs/livoxProto1/livoxProto1.cpp +++ b/commonLibs/livoxProto1/livoxProto1.cpp @@ -10,7 +10,7 @@ extern "C" { void livoxProto1_getOrCreateDeviceReq( const std::string& deviceIdentifier, const std::shared_ptr& componentThread, - int handshakeTimeoutMs, int retryDelayMs, + int commandTimeoutMs, int retryDelayMs, const std::string& smoIp, uint8_t smoSubnetNbits, uint16_t dataPort, uint16_t cmdPort, uint16_t imuPort, smo::Callback callback @@ -28,7 +28,7 @@ void livoxProto1_getOrCreateDeviceReq( // Delegate to DeviceManager protoState.deviceManager->getOrCreateDeviceReq( deviceIdentifier, componentThread, - handshakeTimeoutMs, retryDelayMs, + commandTimeoutMs, retryDelayMs, smoIp, smoSubnetNbits, dataPort, cmdPort, imuPort, callback); diff --git a/commonLibs/livoxProto1/livoxProto1.h b/commonLibs/livoxProto1/livoxProto1.h index b6ba497..4110868 100644 --- a/commonLibs/livoxProto1/livoxProto1.h +++ b/commonLibs/livoxProto1/livoxProto1.h @@ -41,7 +41,7 @@ typedef void livoxProto1_exitFn(void); * Create a new Livox device connection * @param deviceIdentifier The device identifier (broadcast code) * @param componentThread Component thread for async operations - * @param handshakeTimeoutMs Handshake timeout in milliseconds (default: 1000) + * @param commandTimeoutMs Command timeout in milliseconds (default: 1000) * @param retryDelayMs Retry delay in milliseconds (default: 3000) * @param smoIp SMO IP address (empty string for auto-detection) * @param smoSubnetNbits SMO subnet mask bits (e.g., 24 for /24, 16 for /16) @@ -57,7 +57,7 @@ typedef std::function< typedef void livoxProto1_getOrCreateDeviceReqFn( const std::string& deviceIdentifier, const std::shared_ptr& componentThread, - int handshakeTimeoutMs, int retryDelayMs, + int commandTimeoutMs, int retryDelayMs, const std::string& smoIp, uint8_t smoSubnetNbits, uint16_t dataPort, uint16_t cmdPort, uint16_t imuPort, smo::Callback callback); diff --git a/docs/livox-gen1-lidar-dap-spec.md b/docs/livox-gen1-lidar-dap-spec.md index bc75f9a..08d518f 100644 --- a/docs/livox-gen1-lidar-dap-spec.md +++ b/docs/livox-gen1-lidar-dap-spec.md @@ -25,7 +25,7 @@ Each stim-buff-api is designed to work with specific stim-iface libraries that u **Syntax**: ``` -+idev | avia0 | pcloudIntensity | livoxGen1-pcloudIntensity(data-rate-hz=10) | livoxProto1(handshake-timeout-ms=1000,retry-delay-ms=3000,smo-ip=192.168.1.50,smo-subnet-nbits=24) | 3JEDK380010Z39 ++idev | avia0 | pcloudIntensity | livoxGen1-pcloudIntensity(data-rate-hz=10) | livoxProto1(command-timeout-ms=1000,retry-delay-ms=3000,smo-ip=192.168.1.50,smo-subnet-nbits=24) | 3JEDK380010Z39 ``` **Stim-Buff-API**: `livoxGen1-pcloudIntensity` @@ -37,15 +37,15 @@ Each stim-buff-api is designed to work with specific stim-iface libraries that u **Syntax**: ``` -+edev | avia0 | pcloud(format=xyz) | livoxGen1-pcloud(data-rate-hz=10) | livoxProto1(handshake-timeout-ms=1000,retry-delay-ms=3000,smo-ip=192.168.1.50,smo-subnet-nbits=24) | 3JEDK380010Z39 ++edev | avia0 | pcloud(format=xyz) | livoxGen1-pcloud(data-rate-hz=10) | livoxProto1(command-timeout-ms=1000,retry-delay-ms=3000,smo-ip=192.168.1.50,smo-subnet-nbits=24) | 3JEDK380010Z39 ``` **Alternative Format Examples**: ``` -+edev | avia0 | pcloud(format=spherical) | livoxGen1-pcloud(data-rate-hz=10) | livoxProto1(handshake-timeout-ms=1000,retry-delay-ms=3000,smo-ip=192.168.1.50,smo-subnet-nbits=24) | 3JEDK380010Z39 -+edev | avia0 | pcloud(format=spherical-cartesian) | livoxGen1-pcloud(data-rate-hz=10) | livoxProto1(handshake-timeout-ms=1000,retry-delay-ms=3000,smo-ip=192.168.1.50,smo-subnet-nbits=24) | 3JEDK380010Z39 -+edev | avia0 | pcloud(format=dual-cartesian) | livoxGen1-pcloud(data-rate-hz=10) | livoxProto1(handshake-timeout-ms=1000,retry-delay-ms=3000,smo-ip=192.168.1.50,smo-subnet-nbits=24) | 3JEDK380010Z39 -+edev | avia0 | pcloud(format=dual-spherical) | livoxGen1-pcloud(data-rate-hz=10) | livoxProto1(handshake-timeout-ms=1000,retry-delay-ms=3000,smo-ip=192.168.1.50,smo-subnet-nbits=24) | 3JEDK380010Z39 ++edev | avia0 | pcloud(format=spherical) | livoxGen1-pcloud(data-rate-hz=10) | livoxProto1(command-timeout-ms=1000,retry-delay-ms=3000,smo-ip=192.168.1.50,smo-subnet-nbits=24) | 3JEDK380010Z39 ++edev | avia0 | pcloud(format=spherical-cartesian) | livoxGen1-pcloud(data-rate-hz=10) | livoxProto1(command-timeout-ms=1000,retry-delay-ms=3000,smo-ip=192.168.1.50,smo-subnet-nbits=24) | 3JEDK380010Z39 ++edev | avia0 | pcloud(format=dual-cartesian) | livoxGen1-pcloud(data-rate-hz=10) | livoxProto1(command-timeout-ms=1000,retry-delay-ms=3000,smo-ip=192.168.1.50,smo-subnet-nbits=24) | 3JEDK380010Z39 ++edev | avia0 | pcloud(format=dual-spherical) | livoxGen1-pcloud(data-rate-hz=10) | livoxProto1(command-timeout-ms=1000,retry-delay-ms=3000,smo-ip=192.168.1.50,smo-subnet-nbits=24) | 3JEDK380010Z39 ``` **Stim-Buff-API**: `livoxGen1-pcloud` @@ -67,7 +67,7 @@ Each stim-buff-api is designed to work with specific stim-iface libraries that u **Syntax**: ``` -+idev | avia0 | gyro | livoxGen1-gyro(data-rate-hz=100) | livoxProto1(handshake-timeout-ms=1000,retry-delay-ms=3000,smo-ip=192.168.1.50,smo-subnet-nbits=24) | 3JEDK380010Z39 ++idev | avia0 | gyro | livoxGen1-gyro(data-rate-hz=100) | livoxProto1(command-timeout-ms=1000,retry-delay-ms=3000,smo-ip=192.168.1.50,smo-subnet-nbits=24) | 3JEDK380010Z39 ``` **Stim-Buff-API**: `livoxGen1-gyro` @@ -79,7 +79,7 @@ Each stim-buff-api is designed to work with specific stim-iface libraries that u **Syntax**: ``` -+idev | avia0 | accel | livoxGen1-accel(data-rate-hz=100) | livoxProto1(handshake-timeout-ms=1000,retry-delay-ms=3000,smo-ip=192.168.1.50,smo-subnet-nbits=24) | 3JEDK380010Z39 ++idev | avia0 | accel | livoxGen1-accel(data-rate-hz=100) | livoxProto1(command-timeout-ms=1000,retry-delay-ms=3000,smo-ip=192.168.1.50,smo-subnet-nbits=24) | 3JEDK380010Z39 ``` **Stim-Buff-API**: `livoxGen1-accel` @@ -91,10 +91,10 @@ Each stim-buff-api is designed to work with specific stim-iface libraries that u The `livoxProto1` provider accepts the following parameters: -**handshake-timeout-ms** (optional): -- Specifies the timeout for handshake operations when connecting to devices +**command-timeout-ms** / **cmd-timeout-ms** (optional, synonyms): +- Specifies the timeout for command operations when communicating with devices - Value: Integer number of milliseconds -- Example: `handshake-timeout-ms=1000` (1 second timeout) +- Example: `command-timeout-ms=1000` or `cmd-timeout-ms=1000` (1 second timeout) - Default: 1000ms if not specified **retry-delay-ms** (optional): diff --git a/stimBuffApis/livoxGen1/livoxGen1.cpp b/stimBuffApis/livoxGen1/livoxGen1.cpp index fc36166..271443c 100644 --- a/stimBuffApis/livoxGen1/livoxGen1.cpp +++ b/stimBuffApis/livoxGen1/livoxGen1.cpp @@ -554,9 +554,9 @@ extern "C" void livoxGen1_attachDeviceReq( */ /* The Livox Avia will generally respond to a handshake request within - * 50ms. So we set the handshake timeout to 300ms to be safe. + * 5ms. */ - int handshakeTimeoutMs = 5; // Default: 5ms + int commandTimeoutMs = 5; // Default: 5ms /* Based on testing on a Livox Avia, the device will generally resume * sending broadcast advertisement dgrams after about 5 seconds at most. * Generally, it will resume sending them within 1-2 seconds. @@ -572,11 +572,16 @@ extern "C" void livoxGen1_attachDeviceReq( // Parse optional integer parameters from provider params for (const auto& param : desc->providerParams) { - if (param.first == "handshake-timeout-ms") + if (param.first == "cmd-timeout-ms") { - handshakeTimeoutMs = smo::device::DeviceAttachmentSpec + commandTimeoutMs = smo::device::DeviceAttachmentSpec ::parseRequiredParamAsInt( - desc->providerParams, "handshake-timeout-ms"); + desc->providerParams, "cmd-timeout-ms"); + } else if (param.first == "command-timeout-ms") + { + commandTimeoutMs = smo::device::DeviceAttachmentSpec + ::parseRequiredParamAsInt( + desc->providerParams, "command-timeout-ms"); } else if (param.first == "retry-delay-ms") { retryDelayMs = smo::device::DeviceAttachmentSpec @@ -630,7 +635,7 @@ extern "C" void livoxGen1_attachDeviceReq( (*livoxProto1.livoxProto1_getOrCreateDeviceReq)( desc->deviceSelector, // deviceIdentifier (broadcast code) componentThread, - handshakeTimeoutMs, retryDelayMs, + commandTimeoutMs, retryDelayMs, smoIp, smoSubnetNbits, dataPort, cmdPort, imuPort, {request, std::bind(