Skip to content

Commit 6944289

Browse files
teburdnashif
authored andcommitted
sensors: Fix shell missing channel types
The shell tries to decode all channel types and sequential channel indexes. Unfortunately when swapping to channel specs we forgot to reset the channel index for the next channel type to look at. Signed-off-by: Tom Burdick <[email protected]>
1 parent 1a46b7e commit 6944289

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/sensor/sensor_shell.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#include "sensor_shell.h"
2020

21-
LOG_MODULE_REGISTER(sensor_shell);
21+
LOG_MODULE_REGISTER(sensor_shell, CONFIG_SENSOR_LOG_LEVEL);
2222

2323
#define SENSOR_GET_HELP \
2424
"Get sensor data. Channel names are optional. All channels are read " \
@@ -373,6 +373,8 @@ void sensor_shell_processing_callback(int result, uint8_t *buf, uint32_t buf_len
373373

374374
rc = decoder->get_size_info(ch, &base_size, &frame_size);
375375
if (rc != 0) {
376+
LOG_DBG("skipping unsupported channel %s:%d",
377+
sensor_channel_name[ch.chan_type], ch.chan_idx);
376378
/* Channel not supported, skipping */
377379
continue;
378380
}
@@ -387,6 +389,8 @@ void sensor_shell_processing_callback(int result, uint8_t *buf, uint32_t buf_len
387389
}
388390

389391
while (decoder->get_frame_count(buf, ch, &frame_count) == 0) {
392+
LOG_DBG("decoding %d frames from channel %s:%d",
393+
frame_count, sensor_channel_name[ch.chan_type], ch.chan_idx);
390394
fit = 0;
391395
memset(&accumulator_buffer, 0, sizeof(accumulator_buffer));
392396
while (decoder->decode(buf, ch, &fit, 1, decoded_buffer) > 0) {
@@ -518,10 +522,11 @@ void sensor_shell_processing_callback(int result, uint8_t *buf, uint32_t buf_len
518522
ch.chan_idx,
519523
data->shift, accumulator_buffer.count,
520524
PRIsensor_q31_data_arg(*data, 0));
521-
}
525+
}
522526
}
523527
++ch.chan_idx;
524528
}
529+
ch.chan_idx = 0;
525530
}
526531
}
527532

0 commit comments

Comments
 (0)