SApiMgr:attDevReq: use body||world thread for i/e-devs
We now pass in the correct ComponentThread based on the type of device that's being attached.
This commit is contained in:
@@ -43,6 +43,7 @@ typedef int (sal_mlo_initializeIndFn)(void);
|
|||||||
typedef int (sal_mlo_finalizeIndFn)(void);
|
typedef int (sal_mlo_finalizeIndFn)(void);
|
||||||
typedef void (sal_mlo_attachDeviceReqFn)(
|
typedef void (sal_mlo_attachDeviceReqFn)(
|
||||||
const std::shared_ptr<device::DeviceAttachmentSpec>& desc,
|
const std::shared_ptr<device::DeviceAttachmentSpec>& desc,
|
||||||
|
const std::shared_ptr<ComponentThread>& componentThread,
|
||||||
sal_mlo_attachDeviceReqCbFn cb);
|
sal_mlo_attachDeviceReqCbFn cb);
|
||||||
typedef void (sal_mlo_detachDeviceReqFn)(
|
typedef void (sal_mlo_detachDeviceReqFn)(
|
||||||
const std::shared_ptr<device::DeviceAttachmentSpec>& desc,
|
const std::shared_ptr<device::DeviceAttachmentSpec>& desc,
|
||||||
|
|||||||
@@ -51,14 +51,10 @@ static LivoxProto1DllState livoxProto1;
|
|||||||
static std::vector<std::shared_ptr<livoxProto1::Device>> g_attachedDevices;
|
static std::vector<std::shared_ptr<livoxProto1::Device>> g_attachedDevices;
|
||||||
|
|
||||||
// Callback function declarations
|
// Callback function declarations
|
||||||
extern "C" int livoxGen1_initializeInd(void);
|
extern "C" sal_mlo_initializeIndFn livoxGen1_initializeInd;
|
||||||
extern "C" int livoxGen1_finalizeInd(void);
|
extern "C" sal_mlo_finalizeIndFn livoxGen1_finalizeInd;
|
||||||
extern "C" void livoxGen1_attachDeviceReq(
|
extern "C" sal_mlo_attachDeviceReqFn livoxGen1_attachDeviceReq;
|
||||||
const std::shared_ptr<smo::device::DeviceAttachmentSpec>& desc,
|
extern "C" sal_mlo_detachDeviceReqFn livoxGen1_detachDeviceReq;
|
||||||
smo::sense_api::sal_mlo_attachDeviceReqCbFn cb);
|
|
||||||
extern "C" void livoxGen1_detachDeviceReq(
|
|
||||||
const std::shared_ptr<smo::device::DeviceAttachmentSpec>& desc,
|
|
||||||
smo::sense_api::sal_mlo_detachDeviceReqCbFn cb);
|
|
||||||
|
|
||||||
// Sense API descriptor
|
// Sense API descriptor
|
||||||
static const SenseApiDesc livoxGen1ApiDesc = {
|
static const SenseApiDesc livoxGen1ApiDesc = {
|
||||||
@@ -155,6 +151,7 @@ extern "C" int livoxGen1_finalizeInd(void)
|
|||||||
|
|
||||||
extern "C" void livoxGen1_attachDeviceReq(
|
extern "C" void livoxGen1_attachDeviceReq(
|
||||||
const std::shared_ptr<smo::device::DeviceAttachmentSpec>& desc,
|
const std::shared_ptr<smo::device::DeviceAttachmentSpec>& desc,
|
||||||
|
const std::shared_ptr<smo::ComponentThread>& componentThread,
|
||||||
smo::sense_api::sal_mlo_attachDeviceReqCbFn cb
|
smo::sense_api::sal_mlo_attachDeviceReqCbFn cb
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -249,7 +246,7 @@ extern "C" void livoxGen1_attachDeviceReq(
|
|||||||
|
|
||||||
(*livoxProto1.livoxProto1_getOrCreateDeviceReq)(
|
(*livoxProto1.livoxProto1_getOrCreateDeviceReq)(
|
||||||
desc->deviceSelector, // deviceIdentifier (broadcast code)
|
desc->deviceSelector, // deviceIdentifier (broadcast code)
|
||||||
smoThreadingModelDesc.componentThread,
|
componentThread,
|
||||||
handshakeTimeoutMs, retryDelayMs,
|
handshakeTimeoutMs, retryDelayMs,
|
||||||
smoIp, smoSubnetNbits,
|
smoIp, smoSubnetNbits,
|
||||||
dataPort, cmdPort, imuPort,
|
dataPort, cmdPort, imuPort,
|
||||||
|
|||||||
@@ -275,9 +275,13 @@ static int xcbWindow_finalizeInd(void)
|
|||||||
|
|
||||||
static void xcbWindow_attachDeviceReq(
|
static void xcbWindow_attachDeviceReq(
|
||||||
const std::shared_ptr<smo::device::DeviceAttachmentSpec>& desc,
|
const std::shared_ptr<smo::device::DeviceAttachmentSpec>& desc,
|
||||||
|
const std::shared_ptr<smo::ComponentThread>& componentThread,
|
||||||
smo::sense_api::sal_mlo_attachDeviceReqCbFn cb
|
smo::sense_api::sal_mlo_attachDeviceReqCbFn cb
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
// Not used yet, but may be used later.
|
||||||
|
(void)componentThread;
|
||||||
|
|
||||||
g_attachedWindows.emplace_back(
|
g_attachedWindows.emplace_back(
|
||||||
std::make_unique<xcb_window::AttachedWindow>(desc));
|
std::make_unique<xcb_window::AttachedWindow>(desc));
|
||||||
|
|
||||||
|
|||||||
@@ -283,7 +283,30 @@ void SenseApiManager::attachSenseDeviceReq(
|
|||||||
std::string(__func__) + ": attachDeviceReq() is NULL for library '"
|
std::string(__func__) + ": attachDeviceReq() is NULL for library '"
|
||||||
+ lib.libraryPath + "'");
|
+ lib.libraryPath + "'");
|
||||||
}
|
}
|
||||||
lib.senseApiDesc.sal_mgmt_libOps.attachDeviceReq(spec, cb);
|
|
||||||
|
/** EXPLANATION:
|
||||||
|
* We pass in either the body or world thread here, depending on whether
|
||||||
|
* the device is an introspector (idev) or extrospector (edev).
|
||||||
|
*
|
||||||
|
* Introspectors are attached to the body thread; extrospectors are attached
|
||||||
|
* to the world thread.
|
||||||
|
*/
|
||||||
|
std::shared_ptr<ComponentThread> threadForAttachment;
|
||||||
|
if (spec->sensorType == 'e')
|
||||||
|
{
|
||||||
|
threadForAttachment = mind::globalMind->world.thread;
|
||||||
|
std::cout << __func__ << ": Attaching edev " << spec->deviceIdentifier
|
||||||
|
<< " to world thread" << "\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
threadForAttachment = mind::globalMind->body.thread;
|
||||||
|
std::cout << __func__ << ": Attaching non-edev "
|
||||||
|
<< spec->deviceIdentifier << " to body thread" << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
lib.senseApiDesc.sal_mgmt_libOps.attachDeviceReq(
|
||||||
|
spec, threadForAttachment, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SenseApiManager::detachSenseDeviceReq(
|
void SenseApiManager::detachSenseDeviceReq(
|
||||||
|
|||||||
Reference in New Issue
Block a user