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

Fix hang on disconnect of non-compliant devices: Added timeout to RX … #155

Merged
merged 2 commits into from
Dec 16, 2024

Conversation

wiredopposite
Copy link
Contributor

I fixed a hang that would happen when disconnecting some devices by adding a timeout to the RX path, I also added an overflow check to the buffer.

src/pio_usb.c Outdated
pp->usb_rx_buffer[idx++] = data;
crc_receive = (crc_receive >> 8) | (data << 8);
crc_receive_inverse = crc_receive ^ 0xffff;
crc_match = (crc_receive_inverse == crc_prev2);
}
}
if (timeout == 0) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The period between receiving and sending the acknowledgment is time-critical. Could the timeout determination be deferred until after this process?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes as long as the loop doesn't get stuck infinitely and static bool __no_inline_not_in_flash_func(connection_check)(root_port_t *port) gets to see the port it can be wherever, I can move it down after the transaction if the return -1; is even needed, I'll test it out. Would it also be better to use the remainder of int16_t t = 240; at the top of the function for the timer? I wasn't sure how much is expected to be remaining.

@sekigon-gonnoc sekigon-gonnoc merged commit d17f8ef into sekigon-gonnoc:main Dec 16, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants