Update uart.rst example to read all available characters (#1031)

This commit is contained in:
RoganDawes 2021-02-28 08:48:53 +02:00 committed by GitHub
parent 5b27e9a948
commit 966cb7bc1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -49,8 +49,10 @@ With this you can use automations or lambda to set switch or sensor states.
void loop() override {
const int max_line_length = 80;
static char buffer[max_line_length];
if (available() && readline(read(), buffer, max_line_length) > 0) {
publish_state(buffer);
while (available()) {
if(readline(read(), buffer, max_line_length) > 0) {
publish_state(buffer);
}
}
}
};