Accessing the downloaded log data.

Im having trouble accessing the log data when i download it. Am i correct in thinking it is accessed using the setLogMessageHandler method? If so it seems this is never accessed in my case?

Comments

  • Yes, you use setLogMessageHandler to handle logged data.  Please post your code so we can find exactly what is wrong.
  • findViewById(R.id.start_accel).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    loggingModule.startLogging(true);
    accelModule.enableAxisSampling();
    accelModule.start();
    }
    });

    findViewById(R.id.stop_accel).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    accelModule.stop();
    accelModule.disableAxisSampling();
    loggingModule.stopLogging();

    loggingModule.downloadLog(0.1f, new Logging.DownloadHandler() {
    @Override
    public void onProgressUpdate(int nEntriesLeft, int totalEntries) {
    if(nEntriesLeft==0){
    Log.i(LOG_TAG, String.format("Progress= %d / %d", nEntriesLeft,
    totalEntries));


    }
    }
    });



    }
    });
  • @Override
    public void connected() {
    Log.i(LOG_TAG, "Connected");
    try {
    accelModule = mwBoard.getModule(Accelerometer.class);
    accelModule.setOutputDataRate(50f);
    accelModule.routeData().fromAxes()
    .process(new Rss())
    .process(new Average((byte)4))
    .process(new Threshold(0.5f,Threshold.OutputMode.BINARY))
    .split()
    .branch().process(new Comparison(Comparison.Operation.EQ,-1)).log(FREE_FALL_KEY)
    .branch().process(new Comparison(Comparison.Operation.EQ,1)).log(NO_FREE_FALL_KEY)
    .end()
    .commit()
    .onComplete( new AsyncOperation.CompletionHandler<RouteManager>() {
    @Override
    public void failure(Throwable error) {
    Log.i(LOG_TAG, error.toString());
    }
    @Override
    public void success(RouteManager result) {

    result.setLogMessageHandler(FREE_FALL_KEY, new RouteManager.MessageHandler() {
    @Override
    public void process(Message msg) {
    Log.i(LOG_TAG, "Entered Free Fall");
    }
    });

    result.setLogMessageHandler(NO_FREE_FALL_KEY, new RouteManager.MessageHandler() {
    @Override
    public void process(Message msg) {
    Log.i(LOG_TAG, "Left Free Fall");
    }
    });
    }
    });
    debugModule=mwBoard.getModule(Debug.class);
    loggingModule=mwBoard.getModule(Logging.class);
    } catch (UnsupportedModuleException e) {
    Log.i(LOG_TAG, "Cannot Find Module",e);
    }
    }
    });
    mwBoard.connect();
    }
  • The code looks fine.  So, my next questions are:
    • Does the onFailure function return any errors when you are creating the route?
    • Are the other functions of the DownloadHandler called during the download?
    • How many entries are being downloaded?
  • Sometimes but not often i will getting a timeout from onfailure. 
    The receivedUnknownLogEntry was being called until i reset the device and now it isn't.
    it usually says between 2 and 12 total entries. 
  • The problem here is that you need to clean up the board when you're done using it.  You do this by removing the routes when you're done or reset the board.
  • OK but that still doesn't fix the initial problem.
  • Your problem appeared to be related to the other issues discussed in the thread, such as  receivedUnknownLogEntry being called.  If it's not, then it could be that no free fall events are being recorded.  

    A simple way to check if you have logging setup correctly is to just log the raw accelerometer data then see if you can download the sensor data.
  • Yes i have tested it all without logging and it works fine. As i said before now that i've reset the device  receivedUnknownLogEntry is not being called?

  • edited August 2016
    I said to test logging only accelerometer data not to test the processing chain without logging.

    Yes, and as I previously said, one of the potential causes of the problem stated in the OP can be explained by thereceivedUnknownLogEntry function being called.  Hence I asked that you tested logging only accelerometer data.
  • Hi there, jahara, did you solve this issue? 

    I'm trying to calculate distance with a CPRO censor and when I try to run the free fall program that people of Metawere upload to github has the same error as you have, do not pass through the following part of code:

      result.setLogMessageHandler(FREE_FALL_KEY, new RouteManager.MessageHandler() {
    @Override
    public void process(Message msg) {
    Log.i(LOG_TAG, "Entered Free Fall");
    }
    });

    result.setLogMessageHandler(NO_FREE_FALL_KEY, new RouteManager.MessageHandler() {
    @Override
    public void process(Message msg) {
    Log.i(LOG_TAG, "Left Free Fall");
    }
    });
    So for that reason I have the same issue, I'm trying to detect if this board has the calculation of freefall and time of it in order to make Physics and get the height.
    I believe the problem is the comparison part on that request, but don't know why Metaware upload code that do not work.
    Hope you can help me if you solve it.
    Regards,

  • Does streaming the data work for you?
  • Hi Eric, 

    yes, streaming data works perfectly, the problem is when I'm doing a LOG use, I read in some post about delay that board has with bluetooth connection, so I'm trying to solve that and get a good result from it.
    What I'm trying to make is the board detect a vertical Jump in order to measure the distance more or less with a bit error in CM. so i'm thinking on free fall example to do something like this but I'm not able to get a good result and measurements give all the time different so... don't know if this board is ready or has to much error on manufacturing.
    Please if you have a possible code that just exist or something to get an idea what to do, It will be a great help.
    Regards, 
  • I updated the freefall tutorial to use the newest Android API (v2.6.5) which addresses the logging issue
This discussion has been closed.