Logging

I wrote this to configure logging but I'm not sure what conditions would cause the logger to fail. I have the same configuration for other sensors but only some of them will log back the results while some will fail. is there anything I need to configure beforehand that is not explained in the documentation?

mbl_mw_datasignal_log(m_signal, this, [](void* context, MblMwDataLogger* logger) -> void {
                auto h = static_cast<StreamHandler *>(context);
                if (logger != nullptr) {
                    h->m_logger_signal = logger;
                    mbl_mw_logger_subscribe(logger, context, [](void *context, const MblMwData *data) -> void {
                        auto*  handler = static_cast<StreamHandler *>(context);
                        handler->m_data_lock.lock();
                        handler->m_data->push(new StreamEntry(data));
                        handler->m_data_lock.unlock();
                    });

                    printf("logger ready\n");
                } else {
                    printf("Failed to create the logger\n");
                }
            });

https://github.com/GaitRehabilitation/mex-metawear/blob/master/library/src/StreamHandler.cpp

Comments

  • edited September 2018

    I found that connecting to the sensors with the metbase with logging and then running configuration on my end seems to work. Is there something I need to set?

  • here is a sample of the log entries: https://gist.github.com/pollend/e26d9fbdeba6354289326f6f40b606b7

    something happens when the memory fills up or something.

  • The "unknown log entry" error messages suggests that the boards in question were already setup to log sensor data. Reset the boards to ensure they are in a clean state before programming them.

  • what do I call to reset the sensors. the only thing I can find that suggest reset is mbl_mw_metawearboard_tear_down().

    https://mbientlab.com/cppdocs/latest/mblmwmetawearboard.html?highlight=reset

  • Tear down is fine if you want to preserve sensor configurations. Otherwise, you can call
    mbl_mw_debug_reset.

  • edited October 2018

    how do I go about recovering the handlers when I reconnect to an existing board. the Metbase app seems to be capable of this. anonymous signals never seem to quite work and then crashes when I try to download the data. could this be added to the C++ developer documentation?

     for(uint8_t i = 0; i <= 255; ++i){
        MblMwDataLogger* logger = mbl_mw_logger_lookup_id(board,i);
          if(logger) {
                     std::string id(mbl_mw_logger_generate_identifier(logger));
                      wrapper->registerHandler(new StreamHandler(logger, id));
          }
    
    }
    
  • You can serialize the object state if the same machine is doing the configuring and downloading. You will also want to save which log ids are in use.

    https://mbientlab.com/cppdocs/0/advanced_features.html#serialization

    How are you using anonymous signals? MetaBase uses them in the same way outlined in the documentation.

  • I got the serialization working properly. I was trying to use anonymous signals with just the accelerometer but it crashes when I try to download the data. does it only work with component signals?

  • You don't need to use anonymous signals unless you want to download the data to another device.

    Anonymous downloads work with all signals. Post your code and any errors you are able to capture during the crashes.

This discussion has been closed.