Time variable not initialized in transport_fifo_reset
kinimodkoch opened this issue · comments
kinimodkoch commented
In min.c
, the function transport_fifo_reset
uses the now
variable, but does not update it first. I suggest to insert a call to min_time_ms()
.
static void transport_fifo_reset(struct min_context *self)
{
// Clear down the transmission FIFO queue
self->transport_fifo.n_frames = 0;
self->transport_fifo.head_idx = 0;
self->transport_fifo.tail_idx = 0;
self->transport_fifo.n_ring_buffer_bytes = 0;
self->transport_fifo.ring_buffer_tail_offset = 0;
self->transport_fifo.sn_max = 0;
self->transport_fifo.sn_min = 0;
self->transport_fifo.rn = 0;
// Reset the timers
now = min_time_ms(); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< I suggest to insert this line
self->transport_fifo.last_received_anything_ms = now;
self->transport_fifo.last_sent_ack_time_ms = now;
self->transport_fifo.last_received_frame_ms = 0;
}
Bojan Potočnik commented
Function transport_fifo_reset()
is only called from:
min_init_context()
: usually called once during initialization, when thestatic uint32_t now;
is initialized to 0min_poll()
->rx_byte()
->valid_frame_received()
: the value ofnow
is updated inmin_poll()
min_transport_reset()
: usually called in runtime, after callingmin_poll()
min_poll()
is intended to be called every "tick"/loop iteration, so I think it was meant as a feature to only update now
inside this function. This ensures all operations in this processing step will use the same now
time, including any later calls to min_transport_reset()
.