Implement logging to EEPROM in movesense custom firmware

狂风中的少年 提交于 2019-12-10 14:17:46

问题


I'm looking to integrate logging to the EEPROM in my custom movesense firmware. Reading the docs on the logging service, I've verified that I have the logging system configured with my custom whiteboard objects, and that logging is enabled (logging state is set to 3), with the following code:

WB_RES::DataLoggerConfig dConfig;
WB_RES::DataEntry dEntry, dEntry1;
WB_RES::DataLoggerStateValues::Type dlstate = WB_RES::DataLoggerStateValues::Type::DATALOGGER_LOGGING;

dEntry.path = "/App/Object1";
dEntry1.path = "/App/Object2";
dConfig.dataEntries.dataEntry = {dEntry, dEntry1};

result = asyncPut(WB_RES::LOCAL::MEM_DATALOGGER_CONFIG(), AsyncRequestOptions::Empty, dConfig);
if(!wb::RETURN_OKC(result))
  DebugLogger::info("asyncPut::datalogger config threw error: %u", result);

result = asyncPut(WB_RES::LOCAL::MEM_DATALOGGER_STATE(), AsyncRequestOptions::Empty, dlstate);
if(!wb::RETURN_OKC(result))
  DebugLogger::info("asyncPut::datalogger start threw error: %u", result);

The whiteboard object paths I have configured in the yaml file are:

paths: /App/Object1/Subscription:
  <blah, post/delete actions defined>
paths: /App/Object2/Subscription:
  <blah, post/delete actions defined>

First off, is this correct, in getting the movesense firmware to log these whiteboard objects? What is the relationship between the whiteboard path defined in the yaml file to the data entry path that we configure in the code? Do they have to match exactly?

Second, if I have the above correct, then are will the entries be automatically logged when I post a notification to the subscribed consumers (currently done in the onNotify() method), or will I have to create a specific wb::LogEntry object, and populate that, and then do an asyncPost to the MEM_LOGBOOK_ENTRIES() target, like so:

wb::LogEntry foo;
result = asyncPost(WB_RES::LOCAL::MEM_LOGBOOK_ENTRIES(), AsyncRequestOptions::Empty, foo);

If that is the case, are they any helper functions to help populate the wb::LogEntry object, since it looks like you need an id, timestamp, and then the whiteboard data object? Or do we have to generate those on our own?


回答1:


Your basic idea is correct, but there are some details that are a bit off.

First the division of the two components, DataLogger and Logbook:

  • DataLogger takes care of everything to store data to the EEPROM memory
  • Logbook can be used to read data from the EEPROM memory (and to erase it to clean state)

The DataLogger works by subscribing to the paths given in /Mem/DataLogger/Config and then storing the notifications of those subscriptions (there is no need to do anything with the /Logbook/Entries).

Simple flow:

  1. PUT paths to log to /Mem/DataLogger/Config
  2. PUT 3 to /Mem/DataLogger/State to start logging

--- Logging happens here ---

  1. PUT 2 to /Mem/DataLogger/State to stop logging

However there are some details wrong in your code. The result of the Config and State PUT operation comes in the onPutResult() callback. So to be sure that the configuration is correct you must trigger state change after you get status = 200 in the callback of the /Config PUT.

Also there are some limitations on what can be logged. mainly:

  • if there are multiple arrays, they must be all of the same length (like /Meas/IMU9)
  • strings are not supported

To see how the notification value objects are stored into the EEPROM see the /generated/sbem-code/sbem_definitions.cpp. If your type does not appear there, then something in your service yaml is preventing the serialization.

To try out the DataLogger & Logbook API's please see the DataLoggerSample Android app in movesense-mobile-lib repository.



来源:https://stackoverflow.com/questions/50497055/implement-logging-to-eeprom-in-movesense-custom-firmware

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!