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

logf_P fails #18

Open
dragondaud opened this issue Oct 1, 2018 · 1 comment
Open

logf_P fails #18

dragondaud opened this issue Oct 1, 2018 · 1 comment

Comments

@dragondaud
Copy link

dragondaud commented Oct 1, 2018

Exception 3: LoadStoreError: Processor internal physical address or data error during load or store
0x4021ec20: vsnprintf at /Users/igrokhotkov/e/newlib-xtensa/xtensa-lx106-elf/newlib/libc/stdio/../../../.././newlib/libc/stdio/vsnprintf.c line 42
0x401004e4: malloc at C:\Users\daud\Documents\Arduino\hardware\esp8266com\esp8266\cores\esp8266\umm_malloc/umm_malloc.c line 1672
0x4021abc4: operator new[](unsigned int) at C:\Users\daud\Documents\Arduino\hardware\esp8266com\esp8266\cores\esp8266/abi.cpp line 71
0x4021751a: Syslog::vlogf(unsigned short, char const*, __va_list_tag) at C:\Users\daud\Documents\Arduino\libraries\Syslog\src/Syslog.cpp line 38
0x40217568: Syslog::logf(char const*, ...) at C:\Users\daud\Documents\Arduino\libraries\Syslog\src/Syslog.cpp line 38
0x4020d6e3: setup at C:\Users\daud\Documents\Arduino\myClock/myClock.ino line 116

This works as expected:
Serial.printf_P(PSTR("setup: %s, %s, %s, %d, %d \r\n"), location.c_str(), timezone.c_str(), milTime ? "true" : "false", brightness, light);

This does not:
syslog.logf_P(PSTR("setup: %s|%s|%s|%d|%d"), location.c_str(), timezone.c_str(), milTime ? "true" : "false", brightness, light);

My full code is available at https://github.com/dragondaud/myClock

@yunjova
Copy link

yunjova commented Dec 2, 2019

The function "bool Syslog::vlogf_P(uint16_t pri, PGM_P fmt_P, va_list args)" in file Syslog.cpp has a bug which (probably) is the reason for this failure.

Solution:
Replace "vsnprintf(message, len + 1, fmt_P, args);" inside the if statement with "vsnprintf**### _P**(message, len + 1, fmt_P, args);". (Add "_P" to call the correct function.)

Kind regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants