Synchronizing sensor_v1 changes

This commit is contained in:
kurisaw 2024-07-24 09:43:33 +08:00 committed by Meco Man
parent 57bca1a072
commit ab11bd04bf
1 changed files with 8 additions and 6 deletions

View File

@ -281,7 +281,7 @@ static void sensor_polling(int argc, char **argv)
MSH_CMD_EXPORT(sensor_polling, Sensor polling mode test function); MSH_CMD_EXPORT(sensor_polling, Sensor polling mode test function);
#endif #endif
static void sensor(int argc, char **argv) static int sensor(int argc, char **argv)
{ {
static rt_device_t dev = RT_NULL; static rt_device_t dev = RT_NULL;
struct rt_sensor_data data; struct rt_sensor_data data;
@ -310,7 +310,7 @@ static void sensor(int argc, char **argv)
if (dev == RT_NULL) if (dev == RT_NULL)
{ {
LOG_W("Please probe sensor device first!"); LOG_W("Please probe sensor device first!");
return ; return -RT_ERROR;
} }
rt_device_control(dev, RT_SENSOR_CTRL_GET_INFO, &info); rt_device_control(dev, RT_SENSOR_CTRL_GET_INFO, &info);
switch (info.vendor) switch (info.vendor)
@ -431,7 +431,7 @@ static void sensor(int argc, char **argv)
if (dev == RT_NULL) if (dev == RT_NULL)
{ {
LOG_W("Please probe sensor device first!"); LOG_W("Please probe sensor device first!");
return ; return -RT_ERROR;
} }
if (argc == 3) if (argc == 3)
{ {
@ -469,12 +469,12 @@ static void sensor(int argc, char **argv)
if (dev == RT_NULL) if (dev == RT_NULL)
{ {
LOG_E("Can't find device:%s", argv[2]); LOG_E("Can't find device:%s", argv[2]);
return; return -RT_ERROR;
} }
if (rt_device_open(dev, RT_DEVICE_FLAG_RDWR) != RT_EOK) if (rt_device_open(dev, RT_DEVICE_FLAG_RDWR) != RT_EOK)
{ {
LOG_E("open device failed!"); LOG_E("open device failed!");
return; return -RT_ERROR;
} }
rt_device_control(dev, RT_SENSOR_CTRL_GET_ID, &reg); rt_device_control(dev, RT_SENSOR_CTRL_GET_ID, &reg);
LOG_I("device id: 0x%x!", reg); LOG_I("device id: 0x%x!", reg);
@ -483,7 +483,7 @@ static void sensor(int argc, char **argv)
else if (dev == RT_NULL) else if (dev == RT_NULL)
{ {
LOG_W("Please probe sensor first!"); LOG_W("Please probe sensor first!");
return ; return -RT_ERROR;
} }
else if (!strcmp(argv[1], "sr")) else if (!strcmp(argv[1], "sr"))
{ {
@ -510,6 +510,8 @@ static void sensor(int argc, char **argv)
{ {
LOG_W("Unknown command, please enter 'sensor' get help information!"); LOG_W("Unknown command, please enter 'sensor' get help information!");
} }
return RT_EOK;
} }
#ifdef RT_USING_FINSH #ifdef RT_USING_FINSH
MSH_CMD_EXPORT(sensor, sensor test function); MSH_CMD_EXPORT(sensor, sensor test function);