Did not receive data processor id within 250ms Exception
Hello! I'm working on UWP C# app with two MetaMotionR sensors (Firmware 1.4.5). The sensors are set to log quaternion and acceleration data. Though the sensor logging and data download in general works, I oftentimes get the exception "Did not receive data processor id within 250ms" when adding the routes. This seems to happen more often when running the application in release mode (or as installed app) vs debug mode. Any ideas where to go further?
Here is the code snippet and exception thrown:
private const uint _samplingTime = 25;
private readonly Action<IData> _quaternionSub;
private readonly Action<IData> _linAccSub;
// in some initialize function
public void initialize()
{
_quaternionSub = new Action<IData>(data =>
{
// store data for quaternion to array
});
_linAccSub = new Action<IData>(data =>
{
// store data for acceleration to array
});
}
// called once connected to the sensors....
public async Task SetLoggerRoutesAsync()
{
try
{
var sensorFusion = _metawear.GetModule<ISensorFusionBosch>();
sensorFusion.Configure(mode: MbientLab.MetaWear.Core.SensorFusionBosch.Mode.Ndof,
ar: MbientLab.MetaWear.Core.SensorFusionBosch.AccRange._16g,
gr: MbientLab.MetaWear.Core.SensorFusionBosch.GyroRange._2000dps);
var linearLoggerRoute = await sensorFusion.LinearAcceleration.AddRouteAsync(
source => source.Limit(_samplingTime).Log(_linAccSub));
var quaternionLoggerRoute = await sensorFusion.Quaternion.AddRouteAsync(
source => source.Limit(_samplingTime).Log(_quaternionSub));
}
catch(Exception ex)
{
//log exception
}
}
The exception trace:
.....Did not receive data processor id within 250ms at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x21
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0x70
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x38
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task) + 0x17
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() + 0xf
at MbientLab.MetaWear.Impl.TimedTask`1.<Execute>d__3.MoveNext() + 0x268
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x21
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0x70
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x38
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task) + 0x17
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() + 0xf
at MbientLab.MetaWear.Impl.DataProcessor.<queueDataProcessors>d__28.MoveNext() + 0x25a
at MbientLab.MetaWear.Impl.DataProcessor.<queueDataProcessors>d__28.MoveNext() + 0x427
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x21
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0x70
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x38
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task) + 0x17
at MbientLab.MetaWear.Impl.MetaWearBoard.<createRouteAsync>d__73.MoveNext() + 0xf5c
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x21
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0x70
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x38
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task) + 0x17
at MbientLab.MetaWear.Impl.MetaWearBoard.<queueRouteBuilderAsync>d__70.MoveNext() + 0x2e5
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x21
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0x70
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x38
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task) + 0x17
at Bioniks.oTUGApp.Hardware.SensorModule.<SetLoggerRoutesAsync>d__35.MoveNext() + 0x291
at Bioniks.oTUGApp.Hardware.SensorModule.<SetLoggerRoutesAsync>d__35.MoveNext() + 0x390
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x21
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0x70
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x38
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task) + 0x17
at System.Runtime.CompilerServices.TaskAwaiter.GetResult() + 0xb
...
Comments
What do you do when you disconnect from the sensors or are done sampling data?
When done logging data, the following code would be called (few non-sensor related lines removed):
Disconnect would happen separately as there may be multiple sequences recorded (and downloaded) within a connected session. If the sensors created the routes without this exception, then multiple recordings work just fine. In general, this would be the disconnect process.
You need to clean up board resources.
https://mbientlab.com/csdocs/1/metawearboard.html#tear-down
Eric, thanks for the replies. I actually did have a teardown included, just forgot to paste it into the code.
It turned out the issue was related to something else. In my app, the user can connect and disconnect to sensors within the same app life cycle. I wrote a custom device scanner that connects to pre-configured devices. I use MbientLab.MetaWear.Win10.Application.GetMetaWearBoard() to get the device and MbientLab.MetaWear.Win10.Application.RemoveMetaWearBoard() to remove. I did not realize though that I needed to set the 'dispose' flag to true in order to properly clean up. Apparently I still got to the device the next time around calling GetMetaWearBoard(), but initialization or another method would fail with the timeout exception. Adding the dispose flag fixed the issue. The tutorial examples don't seem to demonstrate the use RemoveMetaWearBoard()...