livoxGen1:attach: alloc PcloudStimBuff after getting return mode
This commit is contained in:
@@ -96,6 +96,7 @@ public:
|
||||
public:
|
||||
const std::shared_ptr<smo::device::DeviceAttachmentSpec> spec;
|
||||
std::shared_ptr<PcloudStimulusBuffer> stimBuff;
|
||||
std::shared_ptr<livoxProto1::Device> deviceTmp;
|
||||
|
||||
private:
|
||||
std::unique_ptr<boost::asio::deadline_timer> delayTimer;
|
||||
@@ -113,15 +114,8 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
// Create and add PcloudStimulusBuffer to collection
|
||||
StimulusBuffer::PcloudFormatDesc formatDesc;
|
||||
formatDesc.format = StimulusBuffer::PcloudFormatDesc::Format::XYZI;
|
||||
auto pcloudStimBuff = std::make_shared<PcloudStimulusBuffer>(
|
||||
*context->spec, dev, formatDesc);
|
||||
|
||||
context->stimBuff = pcloudStimBuff;
|
||||
dev->nAttachedStimBuffs++;
|
||||
attachedStimBuffs.push_back(pcloudStimBuff);
|
||||
// Stash device pointer until after getReturnMode succeeds
|
||||
context->deviceTmp = dev;
|
||||
|
||||
if (1 || OptionParser::getOptions().verbose)
|
||||
{
|
||||
@@ -141,7 +135,7 @@ public:
|
||||
{
|
||||
// Initialize timer with device's component thread
|
||||
delayTimer = std::make_unique<boost::asio::deadline_timer>(
|
||||
context->stimBuff->device->componentThread->getIoService());
|
||||
context->deviceTmp->componentThread->getIoService());
|
||||
|
||||
delayTimer->expires_from_now(boost::posix_time::milliseconds(5));
|
||||
delayTimer->async_wait(
|
||||
@@ -164,7 +158,7 @@ public:
|
||||
}
|
||||
|
||||
(*livoxProto1.livoxProto1_device_getReturnModeReq)(
|
||||
context->stimBuff->device,
|
||||
context->deviceTmp,
|
||||
{context, std::bind(
|
||||
&AttachDeviceReq::attachDeviceReq3,
|
||||
context.get(), context,
|
||||
@@ -184,6 +178,16 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
// Create and add PcloudStimulusBuffer to collection now that device is ready
|
||||
StimulusBuffer::PcloudFormatDesc formatDesc;
|
||||
formatDesc.format = StimulusBuffer::PcloudFormatDesc::Format::XYZI;
|
||||
auto pcloudStimBuff = std::make_shared<PcloudStimulusBuffer>(
|
||||
*context->spec, context->deviceTmp, formatDesc);
|
||||
|
||||
context->stimBuff = pcloudStimBuff;
|
||||
context->deviceTmp->nAttachedStimBuffs++;
|
||||
attachedStimBuffs.push_back(pcloudStimBuff);
|
||||
|
||||
if (1 || OptionParser::getOptions().verbose)
|
||||
{
|
||||
std::cout << __func__ << ": Got return mode (" << (int)mode
|
||||
@@ -509,15 +513,15 @@ extern "C" void livoxGen1_attachDeviceReq(
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get return mode first. Don't need delay since this no commands were
|
||||
/* Enable pcloud data first. Don't need delay since no commands were
|
||||
* sent to device prior to us reaching here.
|
||||
*/
|
||||
(*livoxProto1.livoxProto1_device_getReturnModeReq)(
|
||||
(*livoxProto1.livoxProto1_device_enablePcloudDataReq)(
|
||||
pcloudStimBuff->device,
|
||||
{request, std::bind(
|
||||
&AttachDeviceReq::attachDeviceReq3,
|
||||
&AttachDeviceReq::attachDeviceReq5,
|
||||
request.get(), request,
|
||||
std::placeholders::_1, std::placeholders::_2)});
|
||||
std::placeholders::_1)});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user