From 34ce1b194e3647e8a3b8eb614d94b9127fb1e4f9 Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 29 Jun 2021 09:13:07 +0800 Subject: [PATCH] modify sensor model driver Signed-off-by: kevin Change-Id: I28d0e34dd180a9016a0cb82b27d21a52051e654c --- sensor/hal/include/sensor_controller.h | 10 +++++----- sensor/hal/src/sensor_controller.c | 15 ++++++++------- .../common/hdf_sensor_performance_test.cpp | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/sensor/hal/include/sensor_controller.h b/sensor/hal/include/sensor_controller.h index 2ac4d8a54b..cb3429d70b 100644 --- a/sensor/hal/include/sensor_controller.h +++ b/sensor/hal/include/sensor_controller.h @@ -29,11 +29,11 @@ enum SensorIoCmd { }; enum SensorOpsIoCmd { - SENSOR_OPS_IO_CMD_ENABLE = 1, - SENSOR_OPS_IO_CMD_DISABLE = 2, - SENSOR_OPS_IO_CMD_SET_BATCH = 3, - SENSOR_OPS_IO_CMD_SET_MODE = 4, - SENSOR_OPS_IO_CMD_SET_OPTION = 5, + SENSOR_OPS_IO_CMD_ENABLE = 0, + SENSOR_OPS_IO_CMD_DISABLE = 1, + SENSOR_OPS_IO_CMD_SET_BATCH = 2, + SENSOR_OPS_IO_CMD_SET_MODE = 3, + SENSOR_OPS_IO_CMD_SET_OPTION = 4, SENSOR_OPS_IO_CMD_END, }; diff --git a/sensor/hal/src/sensor_controller.c b/sensor/hal/src/sensor_controller.c index 68ac6b827e..ea2c519c1c 100644 --- a/sensor/hal/src/sensor_controller.c +++ b/sensor/hal/src/sensor_controller.c @@ -161,9 +161,10 @@ static int32_t GetSensorInfo(struct SensorInformation **sensor, int32_t *count) int32_t ret = pos->ioService->dispatcher->Dispatch(&pos->ioService->object, SENSOR_IO_CMD_GET_INFO_LIST, NULL, reply); if (ret != SENSOR_SUCCESS) { - HDF_LOGE("%s: Sensor dispatch info failed[%d]", __func__, ret); + HDF_LOGE("%s: Sensor dispatch info failed[%{public}d]", __func__, ret); break; } + pos->sensorCount = GetSensorNumByManagerType(reply); manager->sensorSum += pos->sensorCount; } @@ -217,7 +218,7 @@ static int32_t SendSensorMsg(int32_t sensorId, struct HdfSBuf *msg, struct HdfSB HDF_LOGE("%s: Sensor dispatch failed", __func__); return ret; } - return ret; + return SENSOR_SUCCESS; } static int32_t EnableSensor(int32_t sensorId) @@ -242,7 +243,7 @@ static int32_t EnableSensor(int32_t sensorId) int32_t ret = SendSensorMsg(sensorId, msg, NULL); if (ret != SENSOR_SUCCESS) { - HDF_LOGE("%s: Sensor enable failed, ret[%d]", __func__, ret); + HDF_LOGE("%s: Sensor enable failed, ret[%{public}d]", __func__, ret); } HdfSBufRecycle(msg); @@ -271,7 +272,7 @@ static int32_t DisableSensor(int32_t sensorId) int32_t ret = SendSensorMsg(sensorId, msg, NULL); if (ret != SENSOR_SUCCESS) { - HDF_LOGE("%s: Sensor disable failed, ret[%d]", __func__, ret); + HDF_LOGE("%s: Sensor disable failed, ret[%{public}d]", __func__, ret); } HdfSBufRecycle(msg); @@ -301,7 +302,7 @@ static int32_t SetSensorBatch(int32_t sensorId, int64_t samplingInterval, int64_ int32_t ret = SendSensorMsg(sensorId, msg, NULL); if (ret != SENSOR_SUCCESS) { - HDF_LOGE("%s: Sensor set batch failed, ret[%d]", __func__, ret); + HDF_LOGE("%s: Sensor set batch failed, ret[%{public}d]", __func__, ret); } HdfSBufRecycle(msg); @@ -330,7 +331,7 @@ static int32_t SetSensorMode(int32_t sensorId, int32_t mode) int32_t ret = SendSensorMsg(sensorId, msg, NULL); if (ret != SENSOR_SUCCESS) { - HDF_LOGE("%s: Sensor set mode failed, ret[%d]", __func__, ret); + HDF_LOGE("%s: Sensor set mode failed, ret[%{public}d]", __func__, ret); } HdfSBufRecycle(msg); @@ -359,7 +360,7 @@ static int32_t SetSensorOption(int32_t sensorId, uint32_t option) int32_t ret = SendSensorMsg(sensorId, msg, NULL); if (ret != SENSOR_SUCCESS) { - HDF_LOGE("%s: Sensor set option failed, ret[%d]", __func__, ret); + HDF_LOGE("%s: Sensor set option failed, ret[%{public}d]", __func__, ret); } HdfSBufRecycle(msg); diff --git a/sensor/test/performance/common/hdf_sensor_performance_test.cpp b/sensor/test/performance/common/hdf_sensor_performance_test.cpp index fa8d391cc2..53c614341f 100644 --- a/sensor/test/performance/common/hdf_sensor_performance_test.cpp +++ b/sensor/test/performance/common/hdf_sensor_performance_test.cpp @@ -42,7 +42,7 @@ namespace { float *data = (float*)event->data; if (event->sensorId == SENSOR_ID) { - printf("time [%lld] sensor id [%d] data [%f]\n\r", event->timestamp, event->sensorId, *(data)); + printf("time [%lld] sensor id [%{public}d] data [%f]\n\r", event->timestamp, event->sensorId, *(data)); if (fabs(*data) > 1e-5) { g_sensorDataFlag = 1; } -- Gitee