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

HardwareSerial's flush() method to override the method of the base class Print #2254

Merged
merged 2 commits into from
Jan 22, 2024

Conversation

ilolis
Copy link
Contributor

@ilolis ilolis commented Jan 19, 2024

This PR addresses the following bugs/features

  • Bug: Fixing issue with base class Print's void flush() method not being overridden by derivative HardwareSerial's void flush(uint32_t timeout = 0) method.

The base class Print defines void flush(), while the derivative HardwareSerial defines void flush(uint32_t timeout = 0). The issue was that when using the base class instance pointer, the virtual function of the derivative was not being called. This PR resolves this.

I might be missing something since I am new to this project, so please feel free to correct me :)

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.

LGTM
Thanls @ilolis

@fpistm fpistm added this to In progress in STM32 core based on ST HAL via automation Jan 22, 2024
@fpistm fpistm added this to the 2.8.0 milestone Jan 22, 2024
@fpistm
Copy link
Member

fpistm commented Jan 22, 2024

Tested with:

Stream &myStream = Serial; 

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // print out the value you read:
  myStream.println(sensorValue);
  myStream.flush();
  delay(1);  // delay in between reads for stability
}

@fpistm fpistm merged commit 49b8eef into stm32duino:main Jan 22, 2024
22 checks passed
STM32 core based on ST HAL automation moved this from In progress to Done Jan 22, 2024
tadtruex pushed a commit to TadAtThayer/Arduino_Core_STM32 that referenced this pull request Apr 23, 2024
…ass Print (stm32duino#2254)

* add flush() method to HardwareSerial

* remove default argument
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants