Raspberry pi 3 + Windows IoT + MetaMotionR

Hi,
basically I've written a UWP app wich can stream the sensor data (Gyro, B-field, Accelerometer and sensor fusion) and since it worked very well I wanted to run the app on the raspberry pi 3 with a windows IoT. After the board didn't initialize at all, I tried to run the CS Template of the UWP starter app with one difference: a toggle to switch the LED on and off.
https://github.com/mbientlab/MetaWear-UwpStarter
Again it worked perfectly on my computer (Visual Studio 2017, Windows 10), but the board couldn't initialize when running on the raspberry pi. When running it as a remote device on Visual studio I get always an error at the initialize function (System.InvalidOperationException: 'TaskT_TransitionToFinal_AlreadyCompleted.)
I've already seen some discussions in the forum about a similar issue, but since there wasn't any solution it would be great if someone could help me!

Comments

  • You'll have to debug to code to help me see what could be going on.  Set a breakpoint in the initialize method's callback function and see what the status value is:

    Print out the contents of the managedArray variable in the writeCharacteristic function:

    Does the code behavior differ between your desktop and the raspi3?
  • Thank you for the quick response!

    When running the code on the computer I get the status 0 at the initialize
    function. While for the managed Array I get 26 characters.

    While when running on the raspi3 I get the status 16 first. So basically I
    get the Error timeout: "API initialization timed out.  Try re-pairing
    the MetaWear or moving it closer to the host device". After refreshing and
    reconnecting to the sensor I get the status 0. This time the managed Array only
    has 23 variables.

    Afterwards I get the error as described above.

    Still if I don't click on the refresh button and don't try to reconnect to
    the board, the managed array finishes at 26 variables:

    and I get an error at the mbl_mw_connection_notify_char_changed function
    (Attempted to read or write protected memory). The variables of the managed array change every time I deploy the solution.

  • Computer managed array

    212836064 212836056 212836112
    212836008 212836088 212836000 212836016 212836032 212836248 212836168 212836176
    212836128 212836136 212836216 212836144 212836200 212836224 212836184 212836160
    212836192 212836208  212836232   212836240   212836152  212836296  319355944

    Status 0

    Raspi Managed array:

    153146824 153146896 153146784
    153146792 153146888 153146800 153146808 153146904 153146816 153146832 153146840
    153146848 153146856 153146864 153146872 153146960 153146968 153146912 153146992 153147008
    153146976  85193072 96728256

    Status 16, then 0

    Raspi managed array (without refreshing)

    151009488 151009496 151009512
    151009560 151009440 151009448 151009632 151009640

    151009616 151009624 151009568
    151009576 151009688 151009680 151009584 151009648

    151009656 151009664 151009672
    151009600 151009608 151009592 151009776 151009760

    151009784 97776704

  • Please print the contents of the managedArray variable.  You have simply given me the addresses (or id?) assigned by the CLR for said variable.
  • Sorry for the misunderstanding. Is it correct that the managedArray is an array with two entries? I get the same content for both raspi and computer:
    1,128  2,128  3,128  4,128  5,128  6,128  7,128  8,128  9,128  10,128  11,128  12,128  13,128  15,128  16,128  17,128  18,128  19,128  20,128  21,128  22,128  23,128  24,128  25,128  254,128  11,132

    Afterwards the board initializes when using the computer, whereas I get  an error at the mbl_mw_connection_notify_char_changed function (Attempted to read or write protected memory) when using the raspi 3
  • edited May 4
    Printing array elements is easily done with a foreach loop.  managedArray is not necessarily 2 elements and array size should never be assumed unless it is explicitly initialized with a constant size.

    Given what you have posted, it seems like the pi3 is taking too long to iterate through all of the initialize commands.  Try calling mbl_mw_metawearboard_set_time_for_response with a longer response time to see if the pi3 can initialize without a timeout error.
  • By changing the time for response it finally works! Thank you very much!
    I can stream the sensor data too, but there is quite a delay when streaming on the raspi 3 (about half a sec). I tried to change the connection parameters and changed the connection interval to 7.5 ms, but the sensor fusion is still very slow. Is there any other way to improve the data streaming?
  • edited May 6
    Unfortunately that seems like a Bluetooth driver issue on the Win10 IOT build.  I have not had any problems streaming to a Win10 laptop or the BLU Windows phone in the office.  

    It could also be that the connection interval was not renegotiated upon it updating meaning you'll have to reconnect the board to the Pi after sending the request for the new intervals.

    Have you tried streaming other sensors and at different data rates?
  • By changing the sensor parameters and changing the connection min and max intervals to 20 and 50 ms I get a pretty good data stream. I noticed that the accelerometer and gyro data stream are able to be streamed much faster than the sensor fusion. But after several rearrangements I got the best result with the connection parameters above. Thanks a lot for all the helpful answers!
Sign In or Register to comment.