Streaming accelerometer values from multiple MetaMotionR sensors with C++ API

edited June 2017 in C#
Hello,
I extended the existing Sample UWP App - Freefall detector to stream acc values onto the console from two MetaMotionR sensors. I manage to get it working once in a while but briefly, after which it throws one of the following exceptions inconsistently.

//System.Runtime.InteropServices.SEHException
mbl_mw_acc_set_odr();

//System.AccessViolationException
mbl_mw_connection_notify_char_changed()

My pipeline is something like this:
        public DetectorSetup()
            this.InitializeComponent();

            btleconn = new List<BtleConnection>();
            for (id=0:numDevices)
                // Create two BtleConnection structs 
// Assign read, write characteristics to both.
            initDelegate = new Fn_IntPtr_Int(initialized);

        private void initialized(IntPtr board, int status)
            // Set Response time as 500 ms and ODR: 25 Hz. Write config.
            // Define dataHandlerDelegates for Acc
            // Subscribe to delegates

        private async void writecharacteristic(...)
            // Unchanged...

        private async void readCharacteristic(...)
            // Unchanged...

        protected async override void OnNavigatedTo(NavigationEventArgs e)
            // Get selectedDevices as a list. Tested and works!
            for (id=0:numDevices)
                selectedDevice = selectedDevices[id];
                // Code to register value changed notification on each device

                var tempBTLEConn = btleconn[id];
                board = mbl_mw_metawearboard_create(ref tempBTLEConn);
                boards.Add(board);
                mbl_mw_metawearboard_initialize(board, initDelegate);

        private void start_Click(object sender, RoutedEventArgs e)
            for (id=0:numDevices)
                    // Code to start Streaming acc


        private void stop_Click(object sender, RoutedEventArgs e)
            for (id=0:numDevices)
                // Code to stop Streaming acc

I intend to stream acc & gyr simultaneously over 2 MetaMotionR sensors. Any advice would be appreciated.

Comments

This discussion has been closed.