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

Optimize UART read for lighthouse #1308

Merged
merged 3 commits into from
Aug 24, 2023
Merged

Optimize UART read for lighthouse #1308

merged 3 commits into from
Aug 24, 2023

Conversation

krichardsson
Copy link
Contributor

This PR reduces the CPU load when using the lighthouse system by optimizing the process of reading from the UART.

The current implementation works by using a queue that is filled from an interrupt, triggered when one more byte is available on the UART. The lighthouse task is removing bytes from the queue when reading the next frame and is locking on the queue to get the next byte as soon as possible. This locking (and task switching?) seems to take a long time. This PR uses a vTaskDelay() in a loop to make sure there are enough data in the buffer before reading to avoid the queue lock.

With 4 base stations received CPU load for the LH taks goes down from 21% to 6%.

By increasing the time in the vTaskDelay() to 2, the CPU load goes down one or two % more, but it also adds a delay.

@krichardsson krichardsson merged commit e176751 into master Aug 24, 2023
23 checks passed
@krichardsson krichardsson deleted the krichardsson/lh-uart branch August 24, 2023 12:21
@knmcguire knmcguire added this to the next-release milestone Oct 10, 2023
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