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

Modify UART Class to Use the txBuffer #303

Closed
wants to merge 5 commits into from

Conversation

delta-G
Copy link
Contributor

@delta-G delta-G commented May 6, 2024

This pull request makes changes in Serial.h and Serial.cpp so that the UART class will make use of the TxBuffer. This greatly reduces the amount of time that Serial.print will block, especially for long strings. Currently the class makes no use of the 512 bytes it has reserved for a txBuffer.

I've changed the write functions so that they will load characters into the buffer and start a transmission if one is not already going.

Because the HAL takes a pointer to the data, I added a char variable to read into so the buffer can be advanced. I cannot attempt to send a larger portion of the buffer because the HAL expects contiguous memory and it will break in the case where the string to send rolls over the end of the ring buffer. I will submit another PR later to deal with that if I find a good way.

While it is possible to submit an entire string to the HAL at once, the string is submitted by pointer so it creates a possible race if there is some other code that changes the string before it gets fully printed. By utilizing the txBuffer, this problem is also alleviated.

I have tested this code in several configurations and it appears to work just dandy. Please let me know what you think.

@delta-G delta-G changed the title Use tx buffer Modify UART Class to Use the txBuffer May 6, 2024
@delta-G
Copy link
Contributor Author

delta-G commented May 6, 2024

I am getting the same errors on those WiFiS3 examples without my changes.

@delta-G
Copy link
Contributor Author

delta-G commented May 6, 2024

Sorry for the mess. There was some issue with submodules that created a funny commit in there. The only files I actually changed are cores/Arduino/Serial.h and Serial.cpp. I don't mind re-creating the changes and resubmitting to clean it up if needed.

@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels May 6, 2024
@delta-G
Copy link
Contributor Author

delta-G commented May 6, 2024

I'm going to close this and resubmit with the right files.

@delta-G delta-G closed this May 6, 2024
@per1234 per1234 added the conclusion: duplicate Has already been submitted label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: duplicate Has already been submitted topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants