LivoxGen1: Port to coros
No longer uses CPS. We also found and documented a potential bug in the way we deal with disablePcloudData during detachDeviceReq.
This commit is contained in:
@@ -14,6 +14,7 @@ if(ENABLE_STIMBUFFAPI_livoxGen1)
|
||||
|
||||
add_library(livoxGen1 SHARED
|
||||
livoxGen1.cpp
|
||||
livoxGen1Proto1CpsBridge.cpp
|
||||
pcloudStimulusProducer.cpp
|
||||
livoxPcloudFrameDumper.cpp
|
||||
ioUringAssemblyEngine.cpp
|
||||
@@ -36,6 +37,8 @@ if(ENABLE_STIMBUFFAPI_livoxGen1)
|
||||
|
||||
target_include_directories(livoxGen1 PUBLIC
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${CMAKE_SOURCE_DIR}/include
|
||||
${CMAKE_SOURCE_DIR}/smocore/include
|
||||
${CMAKE_SOURCE_DIR}/commonLibs
|
||||
${URING_INCLUDE_DIRS}
|
||||
${OPENCL_INCLUDE_DIRS}
|
||||
@@ -46,6 +49,7 @@ if(ENABLE_STIMBUFFAPI_livoxGen1)
|
||||
${URING_LIBRARIES}
|
||||
${OPENCL_LIBRARIES}
|
||||
attachmentSupport
|
||||
spinscale
|
||||
)
|
||||
target_link_directories(livoxGen1 PUBLIC
|
||||
${URING_LIBRARY_DIRS}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,57 @@
|
||||
#ifndef LIVOX_GEN1_INTERNAL_H
|
||||
#define LIVOX_GEN1_INTERNAL_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <spinscale/co/invokers.h>
|
||||
#include <user/deviceAttachmentSpec.h>
|
||||
#include <user/senseApiDesc.h>
|
||||
#include <user/stimulusProducer.h>
|
||||
|
||||
#include "livoxGen1.h"
|
||||
#include "pcloudStimulusProducer.h"
|
||||
|
||||
namespace smo::stim_buff {
|
||||
|
||||
struct LivoxProviderParams
|
||||
{
|
||||
int commandTimeoutMs = 5; // Default: 5ms
|
||||
int retryDelayMs = 5250; // Default: 5250ms
|
||||
uint8_t smoSubnetNbits = 24; // Default: /24 subnet
|
||||
uint16_t dataPort = 56000; // Default data port
|
||||
uint16_t cmdPort = 56001; // Default command port
|
||||
uint16_t imuPort = 56002; // Default IMU port
|
||||
std::string smoIp; // Default: empty string (will trigger IP auto-detection)
|
||||
};
|
||||
|
||||
extern const SmoCallbacks *smoHooksPtr;
|
||||
extern SmoThreadingModelDesc smoThreadingModelDesc;
|
||||
extern std::vector<std::shared_ptr<StimulusProducer>> attachedStimulusProducers;
|
||||
|
||||
std::shared_ptr<StimulusProducer> getStimulusProducer(
|
||||
const std::shared_ptr<device::DeviceAttachmentSpec> &spec);
|
||||
|
||||
size_t parseNDgramsPerFrame(
|
||||
const std::shared_ptr<device::DeviceAttachmentSpec> &spec);
|
||||
|
||||
LivoxProviderParams parseLivoxProviderParams(
|
||||
const std::shared_ptr<device::DeviceAttachmentSpec> &desc);
|
||||
|
||||
bool ensureStimBufferAttachedWithoutDuplicates(
|
||||
const std::shared_ptr<PcloudStimulusProducer> &stimProducer,
|
||||
const std::shared_ptr<device::DeviceAttachmentSpec> &spec);
|
||||
|
||||
sscl::co::ViralNonPostingInvoker<int> livoxGen1_initializeCInd();
|
||||
sscl::co::ViralNonPostingInvoker<int> livoxGen1_finalizeCInd();
|
||||
sscl::co::ViralNonPostingInvoker<StimBuffDeviceOpResult> livoxGen1_attachDeviceCReq(
|
||||
const std::shared_ptr<device::DeviceAttachmentSpec> &desc,
|
||||
const std::shared_ptr<sscl::ComponentThread> &componentThread);
|
||||
sscl::co::ViralNonPostingInvoker<StimBuffDeviceOpResult> livoxGen1_detachDeviceCReq(
|
||||
const std::shared_ptr<device::DeviceAttachmentSpec> &desc);
|
||||
|
||||
} // namespace smo::stim_buff
|
||||
|
||||
#endif // LIVOX_GEN1_INTERNAL_H
|
||||
@@ -0,0 +1,89 @@
|
||||
#include "livoxGen1Proto1CpsBridge.h"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace smo::stim_buff {
|
||||
|
||||
sscl::co::ViralNonPostingInvoker<adapters::smo::GetOrCreateDeviceResult>
|
||||
coAwaitGetOrCreateDevice(
|
||||
const std::shared_ptr<sscl::ComponentThread> &componentThread,
|
||||
const std::string &deviceIdentifier,
|
||||
const LivoxProviderParams ¶ms)
|
||||
{
|
||||
if (!livoxProto1.livoxProto1_getOrCreateDeviceReq) {
|
||||
throw std::runtime_error("coAwaitGetOrCreateDevice: proto1 function missing");
|
||||
}
|
||||
|
||||
auto result = co_await adapters::smo::getGetOrCreateDeviceReqAReqAwaiter(
|
||||
componentThread->getIoService(),
|
||||
livoxProto1.livoxProto1_getOrCreateDeviceReq,
|
||||
deviceIdentifier,
|
||||
componentThread,
|
||||
params.commandTimeoutMs,
|
||||
params.retryDelayMs,
|
||||
params.smoIp,
|
||||
params.smoSubnetNbits,
|
||||
params.dataPort,
|
||||
params.cmdPort,
|
||||
params.imuPort);
|
||||
co_return result;
|
||||
}
|
||||
|
||||
sscl::co::ViralNonPostingInvoker<adapters::smo::GetReturnModeResult>
|
||||
coAwaitGetReturnMode(
|
||||
const std::shared_ptr<sscl::ComponentThread> &componentThread,
|
||||
const std::shared_ptr<livoxProto1::Device> &device)
|
||||
{
|
||||
if (!livoxProto1.livoxProto1_device_getReturnModeReq) {
|
||||
throw std::runtime_error("coAwaitGetReturnMode: proto1 function missing");
|
||||
}
|
||||
|
||||
co_return co_await adapters::smo::getDeviceGetReturnModeReqAReqAwaiter(
|
||||
componentThread->getIoService(),
|
||||
livoxProto1.livoxProto1_device_getReturnModeReq,
|
||||
device);
|
||||
}
|
||||
|
||||
sscl::co::ViralNonPostingInvoker<bool> coAwaitEnablePcloudData(
|
||||
const std::shared_ptr<sscl::ComponentThread> &componentThread,
|
||||
const std::shared_ptr<livoxProto1::Device> &device)
|
||||
{
|
||||
if (!livoxProto1.livoxProto1_device_enablePcloudDataReq) {
|
||||
throw std::runtime_error("coAwaitEnablePcloudData: proto1 function missing");
|
||||
}
|
||||
|
||||
co_return co_await adapters::smo::getDeviceEnablePcloudDataReqAReqAwaiter(
|
||||
componentThread->getIoService(),
|
||||
livoxProto1.livoxProto1_device_enablePcloudDataReq,
|
||||
device);
|
||||
}
|
||||
|
||||
sscl::co::ViralNonPostingInvoker<bool> coAwaitDisablePcloudData(
|
||||
const std::shared_ptr<sscl::ComponentThread> &componentThread,
|
||||
const std::shared_ptr<livoxProto1::Device> &device)
|
||||
{
|
||||
if (!livoxProto1.livoxProto1_device_disablePcloudDataReq) {
|
||||
throw std::runtime_error("coAwaitDisablePcloudData: proto1 function missing");
|
||||
}
|
||||
|
||||
co_return co_await adapters::smo::getDeviceDisablePcloudDataReqAReqAwaiter(
|
||||
componentThread->getIoService(),
|
||||
livoxProto1.livoxProto1_device_disablePcloudDataReq,
|
||||
device);
|
||||
}
|
||||
|
||||
sscl::co::ViralNonPostingInvoker<bool> coAwaitDestroyDevice(
|
||||
const std::shared_ptr<sscl::ComponentThread> &componentThread,
|
||||
const std::shared_ptr<livoxProto1::Device> &device)
|
||||
{
|
||||
if (!livoxProto1.livoxProto1_destroyDeviceReq) {
|
||||
throw std::runtime_error("coAwaitDestroyDevice: proto1 function missing");
|
||||
}
|
||||
|
||||
co_return co_await adapters::smo::getDestroyDeviceReqAReqAwaiter(
|
||||
componentThread->getIoService(),
|
||||
livoxProto1.livoxProto1_destroyDeviceReq,
|
||||
device);
|
||||
}
|
||||
|
||||
} // namespace smo::stim_buff
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef LIVOX_GEN1_PROTO1_CPS_BRIDGE_H
|
||||
#define LIVOX_GEN1_PROTO1_CPS_BRIDGE_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <adapters/smo/livoxProto1CpsAwaiters.h>
|
||||
#include <spinscale/co/invokers.h>
|
||||
#include <spinscale/componentThread.h>
|
||||
|
||||
#include "livoxGen1Internal.h"
|
||||
|
||||
namespace smo::stim_buff {
|
||||
|
||||
sscl::co::ViralNonPostingInvoker<adapters::smo::GetOrCreateDeviceResult>
|
||||
coAwaitGetOrCreateDevice(
|
||||
const std::shared_ptr<sscl::ComponentThread> &componentThread,
|
||||
const std::string &deviceIdentifier,
|
||||
const LivoxProviderParams ¶ms);
|
||||
|
||||
sscl::co::ViralNonPostingInvoker<adapters::smo::GetReturnModeResult>
|
||||
coAwaitGetReturnMode(
|
||||
const std::shared_ptr<sscl::ComponentThread> &componentThread,
|
||||
const std::shared_ptr<livoxProto1::Device> &device);
|
||||
|
||||
sscl::co::ViralNonPostingInvoker<bool> coAwaitEnablePcloudData(
|
||||
const std::shared_ptr<sscl::ComponentThread> &componentThread,
|
||||
const std::shared_ptr<livoxProto1::Device> &device);
|
||||
|
||||
sscl::co::ViralNonPostingInvoker<bool> coAwaitDisablePcloudData(
|
||||
const std::shared_ptr<sscl::ComponentThread> &componentThread,
|
||||
const std::shared_ptr<livoxProto1::Device> &device);
|
||||
|
||||
sscl::co::ViralNonPostingInvoker<bool> coAwaitDestroyDevice(
|
||||
const std::shared_ptr<sscl::ComponentThread> &componentThread,
|
||||
const std::shared_ptr<livoxProto1::Device> &device);
|
||||
|
||||
} // namespace smo::stim_buff
|
||||
|
||||
#endif // LIVOX_GEN1_PROTO1_CPS_BRIDGE_H
|
||||
Reference in New Issue
Block a user