Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When retransmitting frames, MIN should check for tx space #47

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions target/min.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static void on_wire_bytes(struct min_context *self, uint8_t id_control, uint8_t

stuffed_tx_byte(self, payload_len, true);

for(i = 0, n = payload_len; n > 0; n--, i++) {
for((void)(i = 0), n = payload_len; n > 0; n--, i++) {
stuffed_tx_byte(self, payload_base[payload_offset], true);
payload_offset++;
payload_offset &= payload_mask;
Expand Down Expand Up @@ -385,9 +385,15 @@ static void valid_frame_received(struct min_context *self)
// Now retransmit the number of frames that were requested
for(i = 0; i < num_nacked; i++) {
struct transport_frame *retransmit_frame = &self->transport_fifo.frames[idx];
transport_fifo_send(self, retransmit_frame);
idx++;
idx &= TRANSPORT_FIFO_SIZE_FRAMES_MASK;
if(ON_WIRE_SIZE(retransmit_frame->payload_len) <= min_tx_space(self->port)) {
transport_fifo_send(self, retransmit_frame);
idx++;
idx &= TRANSPORT_FIFO_SIZE_FRAMES_MASK;
}
else {
min_debug_print("Not enough space to retransmit frame\n");
break;
}
}
}
else {
Expand Down