@@ -1171,13 +1171,21 @@ static void state_collect(const struct shell *sh)
11711171static  void  transport_evt_handler (enum  shell_transport_evt  evt_type , void  * ctx )
11721172{
11731173	struct  shell  * sh  =  (struct  shell  * )ctx ;
1174+ 
1175+ #if  CONFIG_MULTITHREADING 
11741176	enum  shell_signal  sig  =  evt_type  ==  SHELL_TRANSPORT_EVT_RX_RDY 
11751177			      ? SHELL_SIGNAL_RXRDY 
11761178			      : SHELL_SIGNAL_TXDONE ;
11771179
11781180	k_event_post (& sh -> ctx -> signal_event , sig );
1181+ #endif 
1182+ 
1183+ 	if  (evt_type  ==  SHELL_TRANSPORT_EVT_TX_RDY ) {
1184+ 		z_flag_tx_rdy_set (sh , true);
1185+ 	}
11791186}
11801187
1188+ #if  CONFIG_MULTITHREADING 
11811189static  void  shell_log_process (const  struct  shell  * sh )
11821190{
11831191	bool  processed  =  false;
@@ -1201,6 +1209,7 @@ static void shell_log_process(const struct shell *sh)
12011209
12021210	} while  (processed  &&  !k_event_test (& sh -> ctx -> signal_event , SHELL_SIGNAL_RXRDY ));
12031211}
1212+ #endif 
12041213
12051214static  int  instance_init (const  struct  shell  * sh ,
12061215			 const  void  * transport_config ,
@@ -1216,8 +1225,10 @@ static int instance_init(const struct shell *sh,
12161225
12171226	history_init (sh );
12181227
1228+ #if  CONFIG_MULTITHREADING 
12191229	k_event_init (& sh -> ctx -> signal_event );
12201230	k_sem_init (& sh -> ctx -> lock_sem , 1 , 1 );
1231+ #endif 
12211232
12221233	if  (IS_ENABLED (CONFIG_SHELL_STATS )) {
12231234		sh -> stats -> log_lost_cnt  =  0 ;
@@ -1284,6 +1295,7 @@ static int instance_uninit(const struct shell *sh)
12841295	return  0 ;
12851296}
12861297
1298+ #if  CONFIG_MULTITHREADING 
12871299typedef  void  (* shell_signal_handler_t )(const  struct  shell  * sh );
12881300
12891301static  void  shell_signal_handle (const  struct  shell  * sh ,
@@ -1358,6 +1370,7 @@ void shell_thread(void *shell_handle, void *arg_log_backend,
13581370		z_shell_unlock (sh );
13591371	}
13601372}
1373+ #endif 
13611374
13621375int  shell_init (const  struct  shell  * sh , const  void  * transport_config ,
13631376	       struct  shell_backend_config_flags  cfg_flags ,
@@ -1366,16 +1379,19 @@ int shell_init(const struct shell *sh, const void *transport_config,
13661379	__ASSERT_NO_MSG (sh );
13671380	__ASSERT_NO_MSG (sh -> ctx  &&  sh -> iface  &&  sh -> default_prompt );
13681381
1382+ #if  CONFIG_MULTITHREADING 
13691383	if  (sh -> ctx -> tid ) {
13701384		return  - EALREADY ;
13711385	}
1386+ #endif 
13721387
13731388	int  err  =  instance_init (sh , transport_config , cfg_flags );
13741389
13751390	if  (err  !=  0 ) {
13761391		return  err ;
13771392	}
13781393
1394+ #if  CONFIG_MULTITHREADING 
13791395	k_tid_t  tid  =  k_thread_create (sh -> thread ,
13801396				  sh -> stack , CONFIG_SHELL_STACK_SIZE ,
13811397				  shell_thread , (void  * )sh , (void  * )log_backend ,
@@ -1384,6 +1400,7 @@ int shell_init(const struct shell *sh, const void *transport_config,
13841400
13851401	sh -> ctx -> tid  =  tid ;
13861402	k_thread_name_set (tid , sh -> name );
1403+ #endif 
13871404
13881405	return  0 ;
13891406}
@@ -1392,10 +1409,9 @@ void shell_uninit(const struct shell *sh, shell_uninit_cb_t cb)
13921409{
13931410	__ASSERT_NO_MSG (sh );
13941411
1395- 	if  (IS_ENABLED (CONFIG_MULTITHREADING )) {
1396- 		k_event_post (& sh -> ctx -> signal_event , SHELL_SIGNAL_KILL );
1397- 		return ;
1398- 	}
1412+ #if  CONFIG_MULTITHREADING 
1413+ 	k_event_post (& sh -> ctx -> signal_event , SHELL_SIGNAL_KILL );
1414+ #else 
13991415
14001416	int  err  =  instance_uninit (sh );
14011417
@@ -1404,6 +1420,7 @@ void shell_uninit(const struct shell *sh, shell_uninit_cb_t cb)
14041420	} else  {
14051421		__ASSERT_NO_MSG (0 );
14061422	}
1423+ #endif 
14071424}
14081425
14091426int  shell_start (const  struct  shell  * sh )
0 commit comments