You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The way I think we handle this is by providing an F() macro in the base logger, which is defined if there isn't one defined in the logging strategy. This would ensure that logger code doesn't have to change.
We would need a derived strategy which handles F() appropriately, needs to read the string from flash. We can't put this in the base necessarily because we might want to use the logger with unit tests that don't include Arduino.h/WString.h. We should allow swapping to a strategy which just passes these strings through if there's no overriding implementation.
One implication, however, is that the F() macro must be included/defined by the Arduino headers before including the base logger header.
size_t Print::print(const __FlashStringHelper *ifsh) {
PGM_P p = reinterpret_cast<PGM_P>(ifsh);
char buff[128] __attribute__ ((aligned(4)));
auto len = strlen_P(p);
size_t n = 0;
while (n < len) {
int to_write = std::min(sizeof(buff), len - n);
memcpy_P(buff, p, to_write);
auto written = write(buff, to_write);
n += written;
p += written;
if (!written) {
// Some error, write() should write at least 1 byte before returning
break;
}
}
return n;
}
We do not currently handle strings stored in flash via the F() macro.
https://andybrown.me.uk/wk/wp-content/images//avr-gcc-4.7.0/WString.h
https://github.com/esp8266/Arduino/blob/master/cores/esp8266/Print.h
The text was updated successfully, but these errors were encountered: