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