@@ -338,7 +338,7 @@ impl DutPwrThread {
338
338
// as well.
339
339
// Use a queue to notify the calling thread if the priority setup
340
340
// succeeded.
341
- let ( thread_res_tx , mut thread_res_rx ) = bounded ( 1 ) ;
341
+ let ( thread_tx , thread_rx ) = bounded ( 1 ) ;
342
342
343
343
// Spawn a high priority thread that handles the power status
344
344
// in a realtimey fashion.
@@ -353,24 +353,20 @@ impl DutPwrThread {
353
353
let mut volt_filter = MedianFilter :: < 4 > :: new ( ) ;
354
354
let mut curr_filter = MedianFilter :: < 4 > :: new ( ) ;
355
355
356
- let ( tick_weak, request, state) = match realtime_priority ( ) {
357
- Ok ( _) => {
358
- let tick = Arc :: new ( AtomicU32 :: new ( 0 ) ) ;
359
- let tick_weak = Arc :: downgrade ( & tick) ;
356
+ realtime_priority ( ) ?;
360
357
361
- let request = Arc :: new ( AtomicU8 :: new ( OutputRequest :: Idle as u8 ) ) ;
362
- let state = Arc :: new ( AtomicU8 :: new ( OutputState :: Off as u8 ) ) ;
358
+ let ( tick_weak, request, state) = {
359
+ let tick = Arc :: new ( AtomicU32 :: new ( 0 ) ) ;
360
+ let tick_weak = Arc :: downgrade ( & tick) ;
363
361
364
- thread_res_tx
365
- . try_send ( Ok ( ( tick, request. clone ( ) , state. clone ( ) ) ) )
366
- . unwrap ( ) ;
362
+ let request = Arc :: new ( AtomicU8 :: new ( OutputRequest :: Idle as u8 ) ) ;
363
+ let state = Arc :: new ( AtomicU8 :: new ( OutputState :: Off as u8 ) ) ;
367
364
368
- ( tick_weak, request, state)
369
- }
370
- Err ( e) => {
371
- thread_res_tx. try_send ( Err ( e) ) . unwrap ( ) ;
372
- panic ! ( )
373
- }
365
+ thread_tx
366
+ . try_send ( ( tick, request. clone ( ) , state. clone ( ) ) )
367
+ . expect ( "Queue that should be empty wasn't" ) ;
368
+
369
+ ( tick_weak, request, state)
374
370
} ;
375
371
376
372
// The grace period contains the number of loop iterations until
@@ -501,22 +497,18 @@ impl DutPwrThread {
501
497
match req {
502
498
OutputRequest :: Idle => { }
503
499
OutputRequest :: On => {
504
- discharge_line
505
- . set_value ( 1 - DISCHARGE_LINE_ASSERTED )
506
- . unwrap ( ) ;
507
- pwr_line. set_value ( PWR_LINE_ASSERTED ) . unwrap ( ) ;
500
+ discharge_line. set_value ( 1 - DISCHARGE_LINE_ASSERTED ) ?;
501
+ pwr_line. set_value ( PWR_LINE_ASSERTED ) ?;
508
502
state. store ( OutputState :: On as u8 , Ordering :: Relaxed ) ;
509
503
}
510
504
OutputRequest :: Off => {
511
- discharge_line. set_value ( DISCHARGE_LINE_ASSERTED ) . unwrap ( ) ;
512
- pwr_line. set_value ( 1 - PWR_LINE_ASSERTED ) . unwrap ( ) ;
505
+ discharge_line. set_value ( DISCHARGE_LINE_ASSERTED ) ? ;
506
+ pwr_line. set_value ( 1 - PWR_LINE_ASSERTED ) ? ;
513
507
state. store ( OutputState :: Off as u8 , Ordering :: Relaxed ) ;
514
508
}
515
509
OutputRequest :: OffFloating => {
516
- discharge_line
517
- . set_value ( 1 - DISCHARGE_LINE_ASSERTED )
518
- . unwrap ( ) ;
519
- pwr_line. set_value ( 1 - PWR_LINE_ASSERTED ) . unwrap ( ) ;
510
+ discharge_line. set_value ( 1 - DISCHARGE_LINE_ASSERTED ) ?;
511
+ pwr_line. set_value ( 1 - PWR_LINE_ASSERTED ) ?;
520
512
state. store ( OutputState :: OffFloating as u8 , Ordering :: Relaxed ) ;
521
513
}
522
514
}
@@ -528,7 +520,7 @@ impl DutPwrThread {
528
520
Ok ( ( ) )
529
521
} ) ?;
530
522
531
- let ( tick, request, state) = thread_res_rx . next ( ) . await . unwrap ( ) ?;
523
+ let ( tick, request, state) = thread_rx . recv ( ) . await ?;
532
524
533
525
// The request and state topic use the same external path, this way one
534
526
// can e.g. publish "On" to the topic and be sure that the output is
0 commit comments