@@ -67,6 +67,11 @@ static void print_callback(const struct device *dev, const enum stepper_event ev
6767 }
6868}
6969
70+ static bool stepper_device_check (const struct device * dev )
71+ {
72+ return DEVICE_API_IS (stepper , dev ) && device_is_ready (dev );
73+ }
74+
7075static const struct stepper_direction_map stepper_direction_map [] = {
7176 STEPPER_DIRECTION_MAP_ENTRY ("positive" , STEPPER_DIRECTION_POSITIVE ),
7277 STEPPER_DIRECTION_MAP_ENTRY ("negative" , STEPPER_DIRECTION_NEGATIVE ),
@@ -114,7 +119,7 @@ SHELL_DYNAMIC_CMD_CREATE(dsub_stepper_microstep, cmd_stepper_microstep);
114119
115120static void cmd_pos_stepper_motor_name (size_t idx , struct shell_static_entry * entry )
116121{
117- const struct device * dev = shell_device_lookup (idx , NULL );
122+ const struct device * dev = shell_device_filter (idx , stepper_device_check );
118123
119124 entry -> syntax = (dev != NULL ) ? dev -> name : NULL ;
120125 entry -> handler = NULL ;
@@ -126,7 +131,7 @@ SHELL_DYNAMIC_CMD_CREATE(dsub_pos_stepper_motor_name, cmd_pos_stepper_motor_name
126131
127132static void cmd_pos_stepper_motor_name_dir (size_t idx , struct shell_static_entry * entry )
128133{
129- const struct device * dev = shell_device_lookup (idx , NULL );
134+ const struct device * dev = shell_device_filter (idx , stepper_device_check );
130135
131136 if (dev != NULL ) {
132137 entry -> syntax = dev -> name ;
@@ -142,7 +147,7 @@ SHELL_DYNAMIC_CMD_CREATE(dsub_pos_stepper_motor_name_dir, cmd_pos_stepper_motor_
142147
143148static void cmd_pos_stepper_motor_name_microstep (size_t idx , struct shell_static_entry * entry )
144149{
145- const struct device * dev = shell_device_lookup (idx , NULL );
150+ const struct device * dev = shell_device_filter (idx , stepper_device_check );
146151
147152 if (dev != NULL ) {
148153 entry -> syntax = dev -> name ;
0 commit comments