@@ -663,12 +663,13 @@ def _find_oldest_frame(self):
663663 if len (self ._transport_fifo ) == 0 :
664664 raise AssertionError
665665
666+ now_ms = self ._now_ms ()
666667 window_size = (self ._sn_max - self ._sn_min ) & 0xFF
667668 oldest_frame = self ._transport_fifo [0 ] # type: MINFrame
668- longest_elapsed_time = self . _now_ms () - oldest_frame .last_sent_time
669+ longest_elapsed_time = now_ms - oldest_frame .last_sent_time
669670
670671 for i in range (window_size ):
671- elapsed = self . _now_ms () - self ._transport_fifo [i ].last_sent_time
672+ elapsed = now_ms - self ._transport_fifo [i ].last_sent_time
672673 if elapsed >= longest_elapsed_time :
673674 oldest_frame = self ._transport_fifo [i ]
674675 longest_elapsed_time = elapsed
@@ -683,11 +684,12 @@ def poll(self):
683684
684685 :return: array of accepted MIN frames
685686 """
687+ now_ms = self ._now_ms ()
686688 remote_connected = (
687- self . _now_ms () - self ._last_received_anything_ms
689+ now_ms - self ._last_received_anything_ms
688690 ) < self .idle_timeout_ms
689691 remote_active = (
690- self . _now_ms () - self ._last_received_frame_ms
692+ now_ms - self ._last_received_frame_ms
691693 ) < self .idle_timeout_ms
692694
693695 self ._rx_list = []
@@ -704,6 +706,8 @@ def poll(self):
704706 # Frames still to send
705707 frame = self ._transport_fifo_get (n = window_size )
706708 frame .seq = self ._sn_max
709+ self ._last_sent_frame_ms = now_ms
710+ frame .last_sent_time = now_ms
707711 if min_logger .isEnabledFor (DEBUG ):
708712 min_logger .debug (
709713 "Sending new frame id=0x%02X seq=%d len=%d payload=%s" ,
@@ -719,7 +723,7 @@ def poll(self):
719723 if window_size > 0 and remote_connected :
720724 oldest_frame = self ._find_oldest_frame ()
721725 if (
722- self . _now_ms () - oldest_frame .last_sent_time
726+ now_ms - oldest_frame .last_sent_time
723727 > self .frame_retransmit_timeout_ms
724728 ):
725729 min_logger .debug (
@@ -731,7 +735,7 @@ def poll(self):
731735
732736 # Periodically transmit ACK
733737 if (
734- self . _now_ms () - self ._last_sent_ack_time_ms
738+ now_ms - self ._last_sent_ack_time_ms
735739 > self .ack_retransmit_timeout_ms
736740 ):
737741 if remote_active :
0 commit comments