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