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

Remove busy loop from rx_thread #18

Closed
wants to merge 1 commit into from

Conversation

trivialkettle
Copy link

The rx_thread executed a busy loop and loaded a single core to 100%. This change reduces the load significantly.

There would also be another solution by using

        """ process data as long as requested """
        while self.rx_thread_state == USBtin.RX_THREAD_RUNNING:
            buf = self.serial_port.read(max(1, self.serial_port.inWaiting()))
            if buf:
# ...

This read blocks until 1 or inWaiting() bytes are available. Additionally one need to update stop_rx_thread() by adding

        self.serial_port.cancel_read()

to cancel the blocking read.

The rx_thread executed a busy loop and loaded a single core to 100%. This change reduces the load significantly.
@trivialkettle
Copy link
Author

I created a pull request with my other proposed changes in #19 after testing this.

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.

1 participant