@@ -555,6 +555,10 @@ where
555
555
let mut awaiting_synced: Vec < DownlinkSender > = vec ! [ ] ;
556
556
let mut awaiting_linked: Vec < DownlinkSender > = vec ! [ ] ;
557
557
let mut registered: Vec < DownlinkSender > = vec ! [ ] ;
558
+ // Track whether any events have been received while syncing the downlink. While this isn't the
559
+ // nicest thing to have, it's required to distinguish between communicating with a stateless
560
+ // lane and a downlink syncing with a lane that has a type which may be optional.
561
+ let mut sync_event = false ;
558
562
559
563
let result: Result < ( ) , H :: Report > = loop {
560
564
let ( event, is_active) = match task_state. as_mut ( ) . as_pin_mut ( ) {
@@ -653,13 +657,17 @@ where
653
657
trace ! ( "Entering Synced state." ) ;
654
658
dl_state = ReadTaskDlState :: Synced ;
655
659
if is_active {
656
- // `current` will be empty if we're communicating with a stateless lane as
657
- // no event envelope will have been sent. Therefore, we can't use
658
- // `sync_current` as it will send an event notification with an empty body
659
- // and cause the downlink's runtime task envelope decoder will potentially
660
- // fail due to reading an extant. Therefore, delegate the operation to
660
+ // `sync_event` will be false if we're communicating with a stateless lane
661
+ // as no event envelope will have been sent. However, it's valid Recon for
662
+ // an empty event envelope to be sent (consider Option::None) and this must
663
+ // still be sent to the downlink task.
664
+ //
665
+ // If we're linked to a stateless lane, then `sync_current` cannot be used
666
+ // as we will not have received an event envelope as it will dispatch one
667
+ // with the empty buffer and this may cause the downlink task's decoder to
668
+ // fail due to reading an extant read event. Therefore, delegate the operation to
661
669
// `sync_only` which will not send an event notification.
662
- if I :: SINGLE_FRAME_STATE && !current . is_empty ( ) {
670
+ if I :: SINGLE_FRAME_STATE && sync_event {
663
671
sync_current ( & mut awaiting_synced, & mut registered, & current) . await ;
664
672
} else {
665
673
sync_only ( & mut awaiting_synced, & mut registered) . await ;
@@ -675,8 +683,11 @@ where
675
683
break Ok ( ( ) ) ;
676
684
}
677
685
Notification :: Event ( bytes) => {
686
+ sync_event = true ;
687
+
678
688
trace ! ( "Updating the current value." ) ;
679
689
current. clear ( ) ;
690
+
680
691
if let Err ( e) = interpretation. interpret_frame_data ( bytes, & mut current) {
681
692
if let BadFrameResponse :: Abort ( report) = failure_handler. failed_with ( e) {
682
693
break Err ( report) ;
0 commit comments