| 486 | MSH_CMD_EXPORT(sensor_int, Sensor interrupt mode test function); |
| 487 | |
| 488 | static void sensor_polling(int argc, char **argv) |
| 489 | { |
| 490 | rt_uint16_t num = 10; |
| 491 | rt_device_t dev = RT_NULL; |
| 492 | rt_sensor_t sensor; |
| 493 | struct rt_sensor_data data; |
| 494 | rt_size_t res, i; |
| 495 | rt_int32_t delay; |
| 496 | rt_err_t result; |
| 497 | |
| 498 | dev = rt_device_find(argv[1]); |
| 499 | if (dev == RT_NULL) |
| 500 | { |
| 501 | LOG_E("Can't find device:%s", argv[1]); |
| 502 | return; |
| 503 | } |
| 504 | if (argc > 2) |
| 505 | num = atoi(argv[2]); |
| 506 | |
| 507 | sensor = (rt_sensor_t)dev; |
| 508 | delay = sensor->info.acquire_min > 100 ? sensor->info.acquire_min : 100; |
| 509 | |
| 510 | result = rt_device_open(dev, RT_DEVICE_FLAG_RDONLY); |
| 511 | if (result != RT_EOK) |
| 512 | { |
| 513 | LOG_E("open device failed! error code : %d", result); |
| 514 | return; |
| 515 | } |
| 516 | |
| 517 | for (i = 0; i < num; i++) |
| 518 | { |
| 519 | res = rt_device_read(dev, 0, &data, 1); |
| 520 | if (res != 1) |
| 521 | { |
| 522 | LOG_E("read data failed!size is %d", res); |
| 523 | } |
| 524 | else |
| 525 | { |
| 526 | sensor_show_data(i, sensor, &data); |
| 527 | } |
| 528 | rt_thread_mdelay(delay); |
| 529 | } |
| 530 | rt_device_close(dev); |
| 531 | } |
| 532 | MSH_CMD_EXPORT(sensor_polling, Sensor polling mode test function); |
| 533 | |
| 534 | static void sensor_cmd_warning_unknown(void) |
nothing calls this directly
no test coverage detected