Skip to content

Conversation

qqqlab
Copy link
Contributor

@qqqlab qqqlab commented Sep 15, 2025

This PR adds the uint8_t* variant of the readBytes method to USBSerial.h, to make it more similar to the HardwareSerial interface.

Motivation: this PR makes it easier to interchange USBSerial and HardwareSerial in user code.

Signed-off-by: qqqlab <46283638+qqqlab@users.noreply.github.com>
@fpistm fpistm added the enhancement New feature or request label Sep 15, 2025
@fpistm fpistm requested review from Copilot and fpistm September 15, 2025 07:25
@fpistm fpistm added this to the 2.11.1/2.12.0 milestone Sep 15, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds uint8_t* overloads for readBytes and readBytesUntil methods to the USBSerial class to improve API compatibility with HardwareSerial.

  • Added readBytes(uint8_t *buffer, size_t length) method overload
  • Added readBytesUntil(char terminator, uint8_t *buffer, size_t length) method overload
  • Both new methods delegate to existing char* variants using type casting

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@fpistm
Copy link
Member

fpistm commented Sep 15, 2025

Hi @qqqlab
I thought it was already the case thanks the Stream inheritance:

size_t readBytes(uint8_t *buffer, size_t length)
{
return readBytes((char *)buffer, length);
}

Copy link
Member

@fpistm fpistm left a comment

Choose a reason for hiding this comment

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

Thanks for the PR.

@github-project-automation github-project-automation bot moved this from In progress to Reviewer approved in STM32 core based on ST HAL Sep 15, 2025
@fpistm
Copy link
Member

fpistm commented Sep 15, 2025

OK. Just tested and as the virtual is redefined the second have too. Stream one is ignored.

@fpistm fpistm merged commit b7e543b into stm32duino:main Sep 15, 2025
24 checks passed
@github-project-automation github-project-automation bot moved this from Reviewer approved to Done in STM32 core based on ST HAL Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging this pull request may close these issues.

2 participants