Fuser Dataprocessor - Crash on subscribe

Hi there,

I'm able to read gyro and accelerometer data from the board with seperate callback functions (I subscribed seperatly to the acc_signal and the gyro_signal).
For the sake of efficiency I want to use the Fuser Dataprocessor and cut the number of BLE messages in half. Seems easy, but I hit a snag, the program crashes without an obvious error code.

The code I'm using is the one I found in the tutorials:

#include "metawear/processor/fuser.h"
#include "metawear/sensor/accelerometer.h"
#include "metawear/sensor/gyro_bmi160.h"

void setup_adc_delta(MblMwMetaWearBoard* board) {
    static auto proc_created = [](void* context, MblMwDataProcessor* fuser) {
        mbl_mw_datasignal_subscribe((MblMwDataSignal*)fuser, context, [](void* context, const MblMwData* data) {
            auto fused = (MblMwData**)data->value;

            // 0 - acc data
            // 1 - gyro data
            auto acc = (MblMwCartesianFloat*) fused[0]->value;
            auto gyro = (MblMwCartesianFloat*) fused[1]->value;
            printf("acc = (%.3f, %.3f, %.3f), gyro = (%.3f, %.3f, %.3f)\n",
                    acc->x, acc->y, acc->z,gyro->x, gyro->y, gyro->z);

    auto acc_signal = mbl_mw_acc_get_acceleration_data_signal(board);
    auto gyro_signal = mbl_mw_gyro_bmi160_get_rotation_data_signal(board);

    mbl_mw_dataprocessor_fuser_create(acc_signal, &gyro_signal, 1, nullptr, proc_created);

The processor gets created, but the program then crashes when calling the mbl_mw_datasignal_subscribe function, spitting out a register dump which points to mbl_mw_datasignal_subscribe in datasignal.cpp:

Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC      : 0x401b609b  PS      : 0x00060730  A0      : 0x800d2256  A1      : 0x3ffe6a40
A2      : 0x00000000  A3      : 0x00000000  A4      : 0x400d2258  A5      : 0x00000000
A6      : 0x80000020  A7      : 0x3ffc49a4  A8      : 0x800fb934  A9      : 0x3ffe6a20
A10     : 0x00000002  A11     : 0x3f400152  A12     : 0x00060120  A13     : 0x000000fe
A14     : 0x00000001  A15     : 0x00000000  SAR     : 0x00000016  EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000  LBEG    : 0x400919b5  LEND    : 0x400919c5  LCOUNT  : 0xffffffff

Any ideas? :)


  • @Laura Thanks for the response.

    The javascript version looks identical with the difference that the mbl_mw_datasignal_subscribe takes a MblMwDataProcessor* as argument (similar to the Python API, which I've successfully tested).

    In the cpp version this has to be a MblMwDataSignal*, so a cast is needed. (Which is also mentioned in the cpp tutorial).

    The same crash happens when I try to use another dataprocessor.
    Sample frequencies are the same for the gyroscope and accelerometer.

    Allas no solution so far, any more ideas? :#

  • edited June 20

    Can you update to use the latest SDK. The stuff you are using is the old CPP sdk.

    For one,

    #include "metawear/sensor/gyro_bmi160.h" 

    is now

    #include "metawear/sensor/gyro_bosch.h"

    Also as such, you need to make sure you are using the right calls depending on which sensors you are using (mms = bmi270, mmrl = bmi160 for example). This wouldn't work for the MMS but you aren't tell me so I don't really know what sensors you even have:

    auto gyro_signal = mbl_mw_gyro_bmi160_get_rotation_data_signal(board);
  • @Laura The code snippet came from the cpp-tutorial

    I've already adjusted it to the new SDK and confirmed that I can read out the accelerometer and gyroscope seperatly, just when I'm trying to use any dataprocessor the program crashes on calling mbl_mw_datasignal_subscribe. The register dump doesn't give much info even with debug on, just that it crashes the moment it calls it.

    I'm using the MMRL+ sensors, so a BMI160 is used. (which the board also confirmes).

    Is there an updated tutorial for the new SDK?
    Something I can test to narrow it down?

    Thank you for your input!

  • Be careful, the tutorials are just code snippets and copy pasting them is usually not enough.
    As I mentioned in my previous post, did you update the SDK yet? It's at 20.1 currently. I already mentioned the #include as the biggest differentiator.

  • @Laura The SDK version I'm using is the latest version 20.1.
    I've always used this version of the SDK, the #include was an error while making this thread, in the code I've always used the correct #include.

    I'm following the correct setup procedure for the board, I know this because I can subscribe to any other MblMwDataSignal* without problems.

    So I'm following exactly the same setup procedure as with subscribing to the accelerometer and the gyroscope, with the difference that I don't subscribe to the accelerometer and gyropscope but instead:
    1. Create the dataprocessor with the acc_signal and gyro_signal
    2. Wait for the callback
    3. Check if the dataprocessor object is valid
    4. Cast the dataprocessor to a MblMwDataSignal*
    5. Subscribe
    ==> Programs crashes when entering the subscribe function

  • @Laura Any ideas left? :)
    You don't have a minimal code sample with the latest sdk for the fuser dataprocessor?

  • edited June 28

    I just updated the Java and python examples with the latest SDK. Check those out.

    I won't get around to update the CPP docs until later in July since I am working through Android and USB code right now.

Sign In or Register to comment.