1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-07 16:23:38 +03:00

Allow Print::println() to work with PROGMEM strings (#6450)

Adjust the ::write implementation in Print and its overridden copy in
UART to allow it to silentely accept PROGMEM strings (since there is no
write_P macro).

Fixes #6383
This commit is contained in:
Earle F. Philhower, III 2019-08-28 07:59:19 -07:00 committed by GitHub
parent 37bb628019
commit 7436f3802a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -45,7 +45,7 @@ size_t Print::write(const uint8_t *buffer, size_t size) {
size_t n = 0;
while (size--) {
size_t ret = write(*buffer++);
size_t ret = write(pgm_read_byte(buffer++));
if (ret == 0) {
// Write of last byte didn't complete, abort additional processing
break;

View File

@ -56,7 +56,7 @@ class Print {
size_t write(const char *str) {
if(str == NULL)
return 0;
return write((const uint8_t *) str, strlen(str));
return write((const uint8_t *) str, strlen_P(str));
}
virtual size_t write(const uint8_t *buffer, size_t size);
size_t write(const char *buffer, size_t size) {

View File

@ -495,7 +495,7 @@ uart_write(uart_t* uart, const char* buf, size_t size)
size_t ret = size;
const int uart_nr = uart->uart_nr;
while (size--)
uart_do_write_char(uart_nr, *buf++);
uart_do_write_char(uart_nr, pgm_read_byte(buf++));
return ret;
}