Android Logging
I am trying to get the logging functionality working with the current API. It seems to be working fine except not all of the data seems to be getting transferred into an arraylist that I'm trying to dump the results into.
I have a breakpoint after downloading logs and transferring data. I am seeing totalEntries 1054, but my ArrayList size is only 523. Here is my code:
I have a breakpoint after downloading logs and transferring data. I am seeing totalEntries 1054, but my ArrayList size is only 523. Here is my code:
@Override
protected void boardReady() throws UnsupportedModuleException {
accelModule= mwBoard.getModule(Accelerometer.class);
logModule= mwBoard.getModule(Logging.class);
float ACC_FREQ= sharedPreferences.getInt("samplingFrequency", 200);
accelModule.setOutputDataRate(ACC_FREQ);
int rangeIndex = 2;
counter = 0;
if (accelModule instanceof Bmi160Accelerometer) {
accelModule.setAxisSamplingRange(BMI160_RANGES[rangeIndex]);
} else if (accelModule instanceof Mma8452qAccelerometer) {
((Mma8452qAccelerometer) accelModule).configureAxisSampling()
.enableHighPassFilter((byte) 0)
.setFullScaleRange(Mma8452qAccelerometer.FullScaleRange.FSR_8G)
.commit();
}
routeManagerResult = accelModule.routeData().fromAxes().log("accel_log").commit();
routeManagerResult.onComplete(new AsyncOperation.CompletionHandler<RouteManager>() {
@Override
public void success(RouteManager result) {
routeManager = result;
result.setLogMessageHandler("accel_log", new RouteManager.MessageHandler() {
@Override
public void process(Message msg) {
axisData = msg.getData(CartesianFloat.class);
//float x = axisData.x();
float y = axisData.y();
//float z = axisData.z();
accList1.add(counter, y);
counter++;
}
});
}
@Override
public void failure(Throwable error) {
Log.e("test", "Error committing route", error);
}
});
}
This discussion has been closed.
Comments
Here are my Logs:
the numbers represent Useful data/downloaded data/Total Downloadable data
I/data: Progress: 149/301/3016
I/data: Progress: 299/603/3016
I/data: Progress: 448/904/3016
I/data: Progress: 597/1205/3016
I/data: Progress: 747/1507/3016
I/data: Progress: 897/1809/3016
I/data: Progress: 1047/2111/3016
I/data: Progress: 1197/2413/3016
I/data: Progress: 1346/2715/3016
I/data: Progress: 1496/3016/3016
The number of useful data is correct (what I expected for 2 mins' sampling at 12.5Hz). My question is why the board records twice as much data as it should?
Yes, sure.To make sure I reset the board, I even implement this 3 step connection.
Connection Attempt 1: Reset board
board.removeRoutes();
Logging logger = board.getModule(Logging.class);
logger.stopLogging();
accel_module = board.getModule(Bmi160Accelerometer.class);
accel_module.stop();
accel_module.disableAxisSampling();
logger.clearEntries();
board.disconnect();
Connection Attempt 2: Configure Data Routes
Logging logger = board.getModule(Logging.class);
logger.startLogging(true);
accel_module = board.getModule(Bmi160Accelerometer.class);
accel_module.configureAxisSampling()
.setOutputDataRate(Bmi160Accelerometer.OutputDataRate.ODR_12_5_HZ)
.commit();
accel_module.routeData().fromAxes().log(SENSOR_DATA_LOG).commit().onComplete(accelHandler);
accel_module.enableAxisSampling();
accel_module.startLowPower();
Connection Attempt 3: Download data
.....
When this has happened to me it is because the log is full. You have to initiate a log clear and disconnect routine, then reconnect to get it to start working again. I have a method to clear out the logs before it fills up, but it causes complications and connection issues.
Please vote/ request that NOR Flash be used on the Metawear boards to eliminate having to disconnect after clearing logs. See:
We could make it available as a standard board feature, maybe a MetaWearRSUPER next year if there is enough demand for it.
I'm using a simple counter approach right now, but doesn't guarantee.