Skip to content

Commit

Permalink
bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
robamu committed Oct 14, 2022
1 parent f3ea410 commit a3dcf71
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
11 changes: 7 additions & 4 deletions tmtccmd/core/ccsds_backend.py
Expand Up @@ -196,9 +196,14 @@ def mode_to_req(self):
self._state.mode_wrapper.tc_mode = TcMode.IDLE
self._state._req = BackendRequest.CALL_NEXT
else:
if self._state.sender_res.next_entry_is_tc:
if (
not self._state.sender_res.next_entry_is_tc
and not self._state.sender_res.queue_empty
):
self._state._req = BackendRequest.CALL_NEXT
else:
if (
int(self._state.sender_res.longest_rem_delay.microseconds / 1000)
int(self._state.sender_res.longest_rem_delay.microseconds / 1000.0)
> 0
):
self._state._recommended_delay = (
Expand All @@ -207,8 +212,6 @@ def mode_to_req(self):
self._state._req = BackendRequest.DELAY_CUSTOM
else:
self._state._req = BackendRequest.CALL_NEXT
else:
self._state._req = BackendRequest.CALL_NEXT

def poll_tm(self):
"""Poll TM, irrespective of current TM mode"""
Expand Down
15 changes: 9 additions & 6 deletions tmtccmd/tc/ccsds_seq_sender.py
Expand Up @@ -28,6 +28,7 @@ def __init__(self, mode: SenderMode):
self.mode = mode
self.longest_rem_delay: timedelta = timedelta()
self.tc_sent: bool = False
self.queue_empty: bool = False
self.next_entry_is_tc: bool = False


Expand Down Expand Up @@ -103,14 +104,17 @@ def _handle_current_tc_queue(self, com_if: ComInterface):
"""
# Do not use continue anywhere in this while loop for now
if not self.queue_wrapper.queue:
self._current_res.queue_empty = True
if self.no_delay_remaining():
self._proc_wrapper.base = self._queue_wrapper.info
# cache this for last wait time
self._tc_handler.queue_finished_cb(self._proc_wrapper)
self._mode = SenderMode.DONE
return
else:
self._current_res.queue_empty = False
self._check_next_telecommand(com_if)
self._update_largest_delay()
self.__print_rem_timeout(op_divider=self._op_divider)
self._op_divider += 1

Expand Down Expand Up @@ -184,18 +188,17 @@ def handle_non_tc_entry(self, queue_entry: TcQueueEntryBase) -> bool:
f"Waiting for {wait_entry.wait_time.total_seconds() * 1000} milliseconds."
)
self._wait_cd.reset(new_timeout=wait_entry.wait_time)
self._current_res.longest_rem_delay = max(
self._wait_cd.rem_time(), self._send_cd.rem_time()
)
elif queue_entry.etype == TcQueueEntryType.PACKET_DELAY:
timeout_entry = cast_wrapper.to_packet_delay_entry()
self.queue_wrapper.inter_cmd_delay = timeout_entry.delay_time
self._send_cd.reset(new_timeout=timeout_entry.delay_time)
self._current_res.longest_rem_delay = max(
self._wait_cd.rem_time(), self._send_cd.rem_time()
)
is_tc = queue_entry.is_tc()
if is_tc:
self._last_tc = queue_entry
self._last_queue_entry = queue_entry
return is_tc

def _update_largest_delay(self):
self._current_res.longest_rem_delay = max(
self._wait_cd.rem_time(), self._send_cd.rem_time()
)

0 comments on commit a3dcf71

Please sign in to comment.