summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Fennema <fennema@google.com>2016-06-23 11:02:51 -0700
committerBen Fennema <fennema@google.com>2016-06-24 19:12:08 +0000
commitd70b0eebf14885be4a1aab16e1a2375e63693c93 (patch)
tree95a491b4f1f54f919432c1a237300a0ef73b2379
parent2edc92612766640a52dd3b66b22327a480b68f2b (diff)
downloadcontexthub-nougat-dev.tar.gz
hostIntf: skip sensors after multiple failed checks for InitCompletenougat-dev
On sensor error, log will look like: 01-15 06:29:07.462 872 1900 I nanohub : osLog: initSensors: Temperature not ready! 01-15 06:29:07.464 872 1900 I nanohub : osLog: initSensors: Temperature not ready! 01-15 06:29:07.465 872 1900 I nanohub : osLog: initSensors: Temperature not ready! 01-15 06:29:07.466 872 1900 E nanohub : osLog: initSensors: Temperature not ready - skipping! Bug: 29594941 Change-Id: I9ae7de3a24c9cd6773b2c39a33399a1b8728d41a Signed-off-by: Ben Fennema <fennema@google.com> (cherry picked from commit fa6dd561bc6092681a60e26eef9b794fe5c7a8f1)
-rw-r--r--firmware/src/hostIntf.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/firmware/src/hostIntf.c b/firmware/src/hostIntf.c
index 052ba9f9..051e4e51 100644
--- a/firmware/src/hostIntf.c
+++ b/firmware/src/hostIntf.c
@@ -48,6 +48,7 @@
#define MAX_NUM_BLOCKS 280 /* times 256 = 71680 bytes */
#define MIN_NUM_BLOCKS 10 /* times 256 = 2560 bytes */
#define SENSOR_INIT_DELAY 500000000 /* ns */
+#define SENSOR_INIT_ERROR_MAX 4
#define CHECK_LATENCY_TIME 500000000 /* ns */
#define EVT_LATENCY_TIMER EVT_NO_FIRST_USER_EVENT
@@ -610,6 +611,7 @@ static bool initSensors()
bool present, error;
const struct SensorInfo *si;
uint32_t handle;
+ static uint8_t errorCnt = 0;
mTotalBlocks = 0;
mNumSensors = 0;
@@ -617,9 +619,15 @@ static bool initSensors()
for (i = SENS_TYPE_INVALID + 1; i <= SENS_TYPE_LAST_USER; i++) {
for (j = 0, present = 0, error = 0; (si = sensorFind(i, j, &handle)) != NULL; j++) {
if (!sensorGetInitComplete(handle)) {
- osLog(LOG_INFO, "initSensors: %s not ready!\n", si->sensorName);
- timTimerSet(SENSOR_INIT_DELAY, 0, 50, initCompleteCallback, NULL, true);
- return false;
+ if (errorCnt >= SENSOR_INIT_ERROR_MAX) {
+ osLog(LOG_ERROR, "initSensors: %s not ready - skipping!\n", si->sensorName);
+ continue;
+ } else {
+ osLog(LOG_INFO, "initSensors: %s not ready!\n", si->sensorName);
+ timTimerSet(SENSOR_INIT_DELAY, 0, 50, initCompleteCallback, NULL, true);
+ errorCnt ++;
+ return false;
+ }
} else if (!(si->flags1 & SENSOR_INFO_FLAGS1_LOCAL_ONLY)) {
if (!present) {
present = 1;