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:
2025-09-15 12:47:37 -04:00
parent 472184bbbc
commit db8f047322
4 changed files with 35 additions and 10 deletions
+1
View File
@@ -43,6 +43,7 @@ typedef int (sal_mlo_initializeIndFn)(void);
typedef int (sal_mlo_finalizeIndFn)(void);
typedef void (sal_mlo_attachDeviceReqFn)(
const std::shared_ptr<device::DeviceAttachmentSpec>& desc,
const std::shared_ptr<ComponentThread>& componentThread,
sal_mlo_attachDeviceReqCbFn cb);
typedef void (sal_mlo_detachDeviceReqFn)(
const std::shared_ptr<device::DeviceAttachmentSpec>& desc,
+6 -9
View File
@@ -51,14 +51,10 @@ static LivoxProto1DllState livoxProto1;
static std::vector<std::shared_ptr<livoxProto1::Device>> g_attachedDevices;
// Callback function declarations
extern "C" int livoxGen1_initializeInd(void);
extern "C" int livoxGen1_finalizeInd(void);
extern "C" void livoxGen1_attachDeviceReq(
const std::shared_ptr<smo::device::DeviceAttachmentSpec>& desc,
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);
extern "C" sal_mlo_initializeIndFn livoxGen1_initializeInd;
extern "C" sal_mlo_finalizeIndFn livoxGen1_finalizeInd;
extern "C" sal_mlo_attachDeviceReqFn livoxGen1_attachDeviceReq;
extern "C" sal_mlo_detachDeviceReqFn livoxGen1_detachDeviceReq;
// Sense API descriptor
static const SenseApiDesc livoxGen1ApiDesc = {
@@ -155,6 +151,7 @@ extern "C" int livoxGen1_finalizeInd(void)
extern "C" void livoxGen1_attachDeviceReq(
const std::shared_ptr<smo::device::DeviceAttachmentSpec>& desc,
const std::shared_ptr<smo::ComponentThread>& componentThread,
smo::sense_api::sal_mlo_attachDeviceReqCbFn cb
)
{
@@ -249,7 +246,7 @@ extern "C" void livoxGen1_attachDeviceReq(
(*livoxProto1.livoxProto1_getOrCreateDeviceReq)(
desc->deviceSelector, // deviceIdentifier (broadcast code)
smoThreadingModelDesc.componentThread,
componentThread,
handshakeTimeoutMs, retryDelayMs,
smoIp, smoSubnetNbits,
dataPort, cmdPort, imuPort,
+4
View File
@@ -275,9 +275,13 @@ static int xcbWindow_finalizeInd(void)
static void xcbWindow_attachDeviceReq(
const std::shared_ptr<smo::device::DeviceAttachmentSpec>& desc,
const std::shared_ptr<smo::ComponentThread>& componentThread,
smo::sense_api::sal_mlo_attachDeviceReqCbFn cb
)
{
// Not used yet, but may be used later.
(void)componentThread;
g_attachedWindows.emplace_back(
std::make_unique<xcb_window::AttachedWindow>(desc));
+24 -1
View File
@@ -283,7 +283,30 @@ void SenseApiManager::attachSenseDeviceReq(
std::string(__func__) + ": attachDeviceReq() is NULL for library '"
+ 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(