Skip to content

Commit 7436f38

Browse files
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
1 parent 37bb628 commit 7436f38

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

cores/esp8266/Print.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ size_t Print::write(const uint8_t *buffer, size_t size) {
4545

4646
size_t n = 0;
4747
while (size--) {
48-
size_t ret = write(*buffer++);
48+
size_t ret = write(pgm_read_byte(buffer++));
4949
if (ret == 0) {
5050
// Write of last byte didn't complete, abort additional processing
5151
break;

cores/esp8266/Print.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Print {
5656
size_t write(const char *str) {
5757
if(str == NULL)
5858
return 0;
59-
return write((const uint8_t *) str, strlen(str));
59+
return write((const uint8_t *) str, strlen_P(str));
6060
}
6161
virtual size_t write(const uint8_t *buffer, size_t size);
6262
size_t write(const char *buffer, size_t size) {

cores/esp8266/uart.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ uart_write(uart_t* uart, const char* buf, size_t size)
495495
size_t ret = size;
496496
const int uart_nr = uart->uart_nr;
497497
while (size--)
498-
uart_do_write_char(uart_nr, *buf++);
498+
uart_do_write_char(uart_nr, pgm_read_byte(buf++));
499499

500500
return ret;
501501
}

0 commit comments

Comments
 (0)