Hi Ich habe ein Problem mit PROFMEM char* mit vsnprintf. Die Ausgabe ist ok mit F(string) und normalen Parametern. Sobal aber ein F() Parameter angegeben ist funktioniert das ganze nicht mehr. Wie muss ich die arglist Konvertieren und wie sehe ich ob es ein F( string ist?
1 | #define fstr_Test1 F("Test %s") |
2 | #define fstr_TestOn F("on") |
3 | #define str_TestOff "off" |
4 | |
5 | void out(const __FlashStringHelper* pStr, ...); |
6 | |
7 | void setup() { |
8 | Serial.begin(115200); |
9 | out(fstr_Test1, fstr_TestOn); // do not works |
10 | out(fstr_Test1, str_TestOff); // ok works |
11 | } |
12 | |
13 | void loop() { |
14 | } |
15 | |
16 | void out(const __FlashStringHelper* pStr, ...) { |
17 | char* sTemp; |
18 | sTemp = (char*)malloc(100); |
19 | va_list argList; |
20 | va_start(argList, pStr); |
21 | #ifdef __AVR__ |
22 | vsnprintf_P(sTemp, 100, (const char*)pStr, argList); // progmem for AVR |
23 | #else |
24 | vsnprintf(sTemp, 100, (const char*)pStr, argList); // for the rest of the world |
25 | #endif |
26 | va_end(argList); |
27 | Serial.println(sTemp); |
28 | free(sTemp); |
29 | } |