livoxGen1: Make use of livoxProto1_getPcloudDataFdDesc
This commit is contained in:
@@ -116,7 +116,7 @@ livoxProto1_getPcloudDataFdDesc(void)
|
||||
+ ": DeviceManager not initialized");
|
||||
}
|
||||
|
||||
return protoState.deviceManager->udpCommandDemuxer.pcloudDataSocketDesc;
|
||||
return protoState.deviceManager->udpCommandDemuxer.getPcloudDataFdDesc();
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <callback.h>
|
||||
#include <boost/asio/posix/stream_descriptor.hpp>
|
||||
|
||||
// Forward declarations
|
||||
namespace smo {
|
||||
|
||||
@@ -53,6 +53,13 @@ public:
|
||||
return cmdEndpointFdDesc;
|
||||
}
|
||||
|
||||
// Get shared pointer to pcloud data fd for use in IoUringAssemblyEngine
|
||||
std::shared_ptr<boost::asio::posix::stream_descriptor>
|
||||
getPcloudDataFdDesc() const
|
||||
{
|
||||
return pcloudDataSocketDesc;
|
||||
}
|
||||
|
||||
private:
|
||||
void setupSockets();
|
||||
void setupCommandSocket();
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <livoxProto1/device.h>
|
||||
#include "ioUringAssemblyEngine.h"
|
||||
#include "pcloudStimulusBuffer.h"
|
||||
#include "livoxGen1.h"
|
||||
|
||||
namespace smo {
|
||||
namespace stim_buff {
|
||||
@@ -44,7 +45,8 @@ bool IoUringAssemblyEngine::setup()
|
||||
{ return false; }
|
||||
|
||||
// Get UDP socket file descriptor
|
||||
int udpFd = parent.device->pcloudDataSocketDesc->native_handle();
|
||||
int udpFd = (*livoxProto1.livoxProto1_getPcloudDataFdDesc)()
|
||||
->native_handle();
|
||||
if (udpFd < 0)
|
||||
{ return false; }
|
||||
|
||||
|
||||
@@ -45,40 +45,28 @@ getStimBuff(const std::shared_ptr<smo::device::DeviceAttachmentSpec>& spec)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// LivoxProto1 library state
|
||||
struct LivoxProto1DllState
|
||||
// LivoxProto1DllState constructor implementation
|
||||
LivoxProto1DllState::LivoxProto1DllState()
|
||||
: dlopenHandle(nullptr, DlCloser),
|
||||
livoxProto1_main(nullptr),
|
||||
livoxProto1_exit(nullptr),
|
||||
livoxProto1_getOrCreateDeviceReq(nullptr),
|
||||
livoxProto1_destroyDeviceReq(nullptr),
|
||||
livoxProto1_device_enablePcloudDataReq(nullptr),
|
||||
livoxProto1_device_disablePcloudDataReq(nullptr),
|
||||
livoxProto1_device_getReturnModeReq(nullptr),
|
||||
livoxProto1_getPcloudDataFdDesc(nullptr)
|
||||
{}
|
||||
|
||||
// LivoxProto1DllState DlCloser implementation
|
||||
void LivoxProto1DllState::DlCloser(void* handle)
|
||||
{
|
||||
LivoxProto1DllState()
|
||||
: dlopenHandle(nullptr, DlCloser),
|
||||
livoxProto1_main(nullptr),
|
||||
livoxProto1_exit(nullptr),
|
||||
livoxProto1_getOrCreateDeviceReq(nullptr),
|
||||
livoxProto1_destroyDeviceReq(nullptr),
|
||||
livoxProto1_device_enablePcloudDataReq(nullptr),
|
||||
livoxProto1_device_disablePcloudDataReq(nullptr),
|
||||
livoxProto1_device_getReturnModeReq(nullptr)
|
||||
{}
|
||||
|
||||
static void DlCloser(void* handle)
|
||||
{
|
||||
if (handle) {
|
||||
dlclose(handle);
|
||||
}
|
||||
if (handle) {
|
||||
dlclose(handle);
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<void, void(*)(void*)> dlopenHandle;
|
||||
livoxProto1_mainFn *livoxProto1_main;
|
||||
livoxProto1_exitFn *livoxProto1_exit;
|
||||
livoxProto1_getOrCreateDeviceReqFn *livoxProto1_getOrCreateDeviceReq;
|
||||
livoxProto1_destroyDeviceReqFn *livoxProto1_destroyDeviceReq;
|
||||
livoxProto1_device_enablePcloudDataReqFn
|
||||
*livoxProto1_device_enablePcloudDataReq;
|
||||
livoxProto1_device_disablePcloudDataReqFn
|
||||
*livoxProto1_device_disablePcloudDataReq;
|
||||
livoxProto1_device_getReturnModeReqFn *livoxProto1_device_getReturnModeReq;
|
||||
};
|
||||
|
||||
static LivoxProto1DllState livoxProto1;
|
||||
LivoxProto1DllState livoxProto1;
|
||||
|
||||
// Continuation classes for async operations
|
||||
class AttachDeviceReq
|
||||
@@ -470,13 +458,19 @@ extern "C" int livoxGen1_initializeInd(void)
|
||||
dlsym(
|
||||
livoxProto1.dlopenHandle.get(),
|
||||
"livoxProto1_device_getReturnModeReq"));
|
||||
livoxProto1.livoxProto1_getPcloudDataFdDesc = reinterpret_cast<
|
||||
livoxProto1_getPcloudDataFdDescFn *>(
|
||||
dlsym(
|
||||
livoxProto1.dlopenHandle.get(),
|
||||
"livoxProto1_getPcloudDataFdDesc"));
|
||||
|
||||
if (!livoxProto1.livoxProto1_main || !livoxProto1.livoxProto1_exit
|
||||
|| !livoxProto1.livoxProto1_getOrCreateDeviceReq
|
||||
|| !livoxProto1.livoxProto1_destroyDeviceReq
|
||||
|| !livoxProto1.livoxProto1_device_enablePcloudDataReq
|
||||
|| !livoxProto1.livoxProto1_device_disablePcloudDataReq
|
||||
|| !livoxProto1.livoxProto1_device_getReturnModeReq)
|
||||
|| !livoxProto1.livoxProto1_device_getReturnModeReq
|
||||
|| !livoxProto1.livoxProto1_getPcloudDataFdDesc)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
std::string(__func__) +
|
||||
|
||||
Reference in New Issue
Block a user