Log download handler

Can someone explain more about how mbl_mw_logging_download and MblMwLogDownloadHandler work?

I can download logged data by subscribing to the logger signal (logging accelerometer samples), but I notice that for each sample downloaded, mbl_mw_logging_download calls received_unknown_entry instead of received_progress_update. Even though I'm getting the accelerometer samples, I think I'm doing something wrong somewhere. What does the id argument mean in received_unknown_entry?

Here's an example of the kind of output I get. it looks like for every sample, received_unknown_entry is called twice.

1478016592925 | (-0.075439453125, 0.0534057617188, 1.04595947266)
1478016592925 | received unknown log entry: id = 2
1478016592925 | received unknown log entry: id = 3

Comments

  • Can you post your code?  It sounds like you have setup logging but did not remove them before restarting your app resulting in accelerometer data being logged twice on board.

    The received_unknown_entry callback function is only called if the API doesn't know what to do with the received log data which typically only happens in the aforementioned app restart case or if you connect to a board that was not configured by your device.  The log id is used by the API for this check.
  • edited November 2016
    Thanks Eric. That's definitely what's happening. I looked into it a little more and figured out most of what's going on. I still have two issues though:

    1. No matter what sample rate I set on the device, the accelerometer always samples at 6.25 Hz.

    2. Despite the fact that I call tear_down and free before exiting, the logger doesn't seem to be removed from the board (causing the problem I mentioned in the previous post).

    Here is a link to the test script I wrote. It uses the GATT communication backend from pymetawear. Other parts were written based on the python unit tests and the windows freefall-detector example project. Am I doing anything out of the ordinary?

    (It's also probably worthwhile to mention that I tested this on a couple different CPRO devices, all using the latest firmware)

    J.
  • edited November 2016
    You mixed up mbl_mw_acc_set_odr with mbl_mw_acc_bmi160_set_odr at line 220, assuming you are using sample_rate_param instead of sample_rate.
  • Thanks! That resolved problem 1. I resolved problem 2 by waiting a little between calling teardown and disconnecting from the backend.

    J.
  • OK, I have a new question. I'm trying to log accelerometer and gyroscope data. When I download, I get the following error:

    Traceback (most recent call last):
      File "_ctypes/callbacks.c", line 314, in 'calling callback function'
    TypeError: on_notification() takes exactly 3 arguments (2 given)
    Illegal instruction (core dumped)

    This error probably means a  particular function (below) in pygatt isn't being passed all the arguments it expects, but I can't tell which argument it's missing.

    class Requester(GATTRequester):
        def on_notification(self, handle, data):
            print("- notification on handle: {}\n".format(handle))

    The script runs fine when I only log from one of the sensors (accel or gyro). I get the feeling I'm initializing the loggers wrong (test script is on github). Has anyone accomplished something similar to this?

    J.

  • Hi, I tried the same thing as you, starting from your code. The problem is in L307 or L292: the data_handler passed to the logging_subscribe function may be reclaimed later on and thus the C++ code may call into garbage. You can fix it by doing something like self.gyro_data_handler_ptr = ... .
  • Thanks! I came to the same conclusion (and fixed the script) last night but haven't updated the repo yet.

    J.
  • (For anyone from the future reading this, the script has been updated.)
This discussion has been closed.