summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorMeco Man <[email protected]>2022-12-22 16:42:02 -0500
committerMan, Jianting (Meco) <[email protected]>2022-12-26 02:10:30 -0500
commit8971545d8e6933b039c8fed3b2f6508f06a64442 (patch)
treecf49de2a9e143d04c8b261f0f8b669d9c469ac34 /components
parenta2676b0544d5f1b1102e8ecf31610b58053698e8 (diff)
[sensor] improve commands
Diffstat (limited to 'components')
-rwxr-xr-xcomponents/drivers/Kconfig1
-rw-r--r--components/drivers/sensor/sensor_cmd.c5
2 files changed, 4 insertions, 2 deletions
diff --git a/components/drivers/Kconfig b/components/drivers/Kconfig
index 735347bcbc..52d735c941 100755
--- a/components/drivers/Kconfig
+++ b/components/drivers/Kconfig
@@ -369,6 +369,7 @@ config RT_USING_SENSOR
if RT_USING_SENSOR
config RT_USING_SENSOR_CMD
bool "Using Sensor cmd"
+ select PKG_USING_RT_VSNPRINTF_FULL
default y
endif
diff --git a/components/drivers/sensor/sensor_cmd.c b/components/drivers/sensor/sensor_cmd.c
index 59aab3e57e..107475e3f2 100644
--- a/components/drivers/sensor/sensor_cmd.c
+++ b/components/drivers/sensor/sensor_cmd.c
@@ -362,7 +362,7 @@ static void sensor_fifo_rx_entry(void *parameter)
struct rt_sensor_data *data = RT_NULL;
rt_size_t res, i;
- data = (struct rt_sensor_data *)rt_malloc(sizeof(struct rt_sensor_data) * sensor->info.fifo_max);
+ data = (struct rt_sensor_data *)rt_calloc(sensor->info.fifo_max, sizeof(struct rt_sensor_data));
if (data == RT_NULL)
{
LOG_E("Memory allocation failed!");
@@ -564,7 +564,6 @@ static void sensor(int argc, char **argv)
rt_kprintf("name :%s\n", sensor->info.name);
rt_kprintf("type: :%s\n", sensor_get_type_name(&sensor->info));
rt_kprintf("vendor :%s\n", sensor_get_vendor_name(&sensor->info));
- rt_kprintf("interface :%s\n", sensor_get_intf_name(sensor));
rt_kprintf("unit :%s\n", sensor_get_unit_name(&sensor->info));
rt_kprintf("fetch data:%s\n", sensor_get_fetch_mode_name(&sensor->info));
rt_kprintf("power :%s\n", sensor_get_power_mode_name(&sensor->info));
@@ -575,6 +574,8 @@ static void sensor(int argc, char **argv)
rt_kprintf("error :%f\n", sensor->info.accuracy.error);
rt_kprintf("acquire min:%fms\n", sensor->info.acquire_min);
rt_kprintf("fifo max :%d\n", sensor->info.fifo_max);
+ rt_kprintf("interface type :%s\n", sensor_get_intf_name(sensor));
+ rt_kprintf("interface device :%s\n", sensor->config.intf.dev_name);
}
else if (!strcmp(argv[1], "read"))
{