@@ -1171,19 +1171,16 @@ static void state_collect(const struct shell *sh)
1171
1171
static void transport_evt_handler (enum shell_transport_evt evt_type , void * ctx )
1172
1172
{
1173
1173
struct shell * sh = (struct shell * )ctx ;
1174
- struct k_poll_signal * signal ;
1174
+ enum shell_signal sig = evt_type == SHELL_TRANSPORT_EVT_RX_RDY
1175
+ ? SHELL_SIGNAL_RXRDY
1176
+ : SHELL_SIGNAL_TXDONE ;
1175
1177
1176
- signal = (evt_type == SHELL_TRANSPORT_EVT_RX_RDY ) ?
1177
- & sh -> ctx -> signals [SHELL_SIGNAL_RXRDY ] :
1178
- & sh -> ctx -> signals [SHELL_SIGNAL_TXDONE ];
1179
- k_poll_signal_raise (signal , 0 );
1178
+ k_event_post (& sh -> ctx -> signal_event , sig );
1180
1179
}
1181
1180
1182
1181
static void shell_log_process (const struct shell * sh )
1183
1182
{
1184
1183
bool processed = false;
1185
- int signaled = 0 ;
1186
- int result ;
1187
1184
1188
1185
do {
1189
1186
if (!IS_ENABLED (CONFIG_LOG_MODE_IMMEDIATE )) {
@@ -1193,9 +1190,6 @@ static void shell_log_process(const struct shell *sh)
1193
1190
sh -> log_backend );
1194
1191
}
1195
1192
1196
- struct k_poll_signal * signal =
1197
- & sh -> ctx -> signals [SHELL_SIGNAL_RXRDY ];
1198
-
1199
1193
z_shell_print_prompt_and_cmd (sh );
1200
1194
1201
1195
/* Arbitrary delay added to ensure that prompt is
@@ -1205,9 +1199,7 @@ static void shell_log_process(const struct shell *sh)
1205
1199
k_sleep (K_MSEC (15 ));
1206
1200
}
1207
1201
1208
- k_poll_signal_check (signal , & signaled , & result );
1209
-
1210
- } while (processed && !signaled );
1202
+ } while (processed && !k_event_test (& sh -> ctx -> signal_event , SHELL_SIGNAL_RXRDY ));
1211
1203
}
1212
1204
1213
1205
static int instance_init (const struct shell * sh ,
@@ -1224,16 +1216,9 @@ static int instance_init(const struct shell *sh,
1224
1216
1225
1217
history_init (sh );
1226
1218
1219
+ k_event_init (& sh -> ctx -> signal_event );
1227
1220
k_mutex_init (& sh -> ctx -> wr_mtx );
1228
1221
1229
- for (int i = 0 ; i < SHELL_SIGNALS ; i ++ ) {
1230
- k_poll_signal_init (& sh -> ctx -> signals [i ]);
1231
- k_poll_event_init (& sh -> ctx -> events [i ],
1232
- K_POLL_TYPE_SIGNAL ,
1233
- K_POLL_MODE_NOTIFY_ONLY ,
1234
- & sh -> ctx -> signals [i ]);
1235
- }
1236
-
1237
1222
if (IS_ENABLED (CONFIG_SHELL_STATS )) {
1238
1223
sh -> stats -> log_lost_cnt = 0 ;
1239
1224
}
@@ -1302,19 +1287,15 @@ static int instance_uninit(const struct shell *sh)
1302
1287
typedef void (* shell_signal_handler_t )(const struct shell * sh );
1303
1288
1304
1289
static void shell_signal_handle (const struct shell * sh ,
1305
- enum shell_signal sig_idx ,
1290
+ enum shell_signal sig ,
1306
1291
shell_signal_handler_t handler )
1307
1292
{
1308
- struct k_poll_signal * sig = & sh -> ctx -> signals [sig_idx ];
1309
- int set ;
1310
- int res ;
1311
-
1312
- k_poll_signal_check (sig , & set , & res );
1313
-
1314
- if (set ) {
1315
- k_poll_signal_reset (sig );
1316
- handler (sh );
1293
+ if (!k_event_test (& sh -> ctx -> signal_event , sig )) {
1294
+ return ;
1317
1295
}
1296
+
1297
+ k_event_clear (& sh -> ctx -> signal_event , sig );
1298
+ handler (sh );
1318
1299
}
1319
1300
1320
1301
static void kill_handler (const struct shell * sh )
@@ -1354,20 +1335,13 @@ void shell_thread(void *shell_handle, void *arg_log_backend,
1354
1335
}
1355
1336
1356
1337
while (true) {
1357
- /* waiting for all signals except SHELL_SIGNAL_TXDONE */
1358
- err = k_poll (sh -> ctx -> events , SHELL_SIGNAL_TXDONE ,
1338
+ k_event_wait (& sh -> ctx -> signal_event ,
1339
+ SHELL_SIGNAL_RXRDY |
1340
+ SHELL_SIGNAL_LOG_MSG |
1341
+ SHELL_SIGNAL_KILL ,
1342
+ false,
1359
1343
K_FOREVER );
1360
1344
1361
- if (err != 0 ) {
1362
- if (k_mutex_lock (& sh -> ctx -> wr_mtx , SHELL_TX_MTX_TIMEOUT ) != 0 ) {
1363
- return ;
1364
- }
1365
- z_shell_fprintf (sh , SHELL_ERROR ,
1366
- "Shell thread error: %d" , err );
1367
- k_mutex_unlock (& sh -> ctx -> wr_mtx );
1368
- return ;
1369
- }
1370
-
1371
1345
k_mutex_lock (& sh -> ctx -> wr_mtx , K_FOREVER );
1372
1346
1373
1347
shell_signal_handle (sh , SHELL_SIGNAL_KILL , kill_handler );
@@ -1419,13 +1393,7 @@ void shell_uninit(const struct shell *sh, shell_uninit_cb_t cb)
1419
1393
__ASSERT_NO_MSG (sh );
1420
1394
1421
1395
if (IS_ENABLED (CONFIG_MULTITHREADING )) {
1422
- struct k_poll_signal * signal =
1423
- & sh -> ctx -> signals [SHELL_SIGNAL_KILL ];
1424
-
1425
- sh -> ctx -> uninit_cb = cb ;
1426
- /* signal kill message */
1427
- (void )k_poll_signal_raise (signal , 0 );
1428
-
1396
+ k_event_post (& sh -> ctx -> signal_event , SHELL_SIGNAL_KILL );
1429
1397
return ;
1430
1398
}
1431
1399
0 commit comments