I'm using printf() in my code for ESP8266 and found a weird phenomenon. In the setup printf(\n) generates me a CRLF but ones entered in the Loop() in one of the function calls it doesn't work any more. In this function call I have a
printf("Connected to: SSID: \t %-20s\n",WiFi.SSID(wifi.netindex).c_str() ); which works fine but ones i add a \n to the beginning and change it to printf("\nConnected to: SSID: \t %-20s\n",WiFi.SSID(wifi.netindex).c_str() ); it doesn't display anything at all
Does any one can give me and idea what going on.
An other strange behavior I saw with printf() in combination with Serial.print(). if you mix them than the screen output is not generated in the sequence the functions are used in the code. Print lines later in the code are earlier displayed. Are the printf() streams and Serial.print() streams independent processed by the RTOS of the ESP? and is this the cause of the problem?
I hope one of you can help me.
Thanks Oscar Goos
printf is a variadic function, so it needs some information about the types of the arguments. That's the job of the format specifiers (eg. %d).
%d tells printf to expect an int typed argument, which your warning messages are telling you: warning: format %d expects argument of type int
However, the types you're giving it aren't ints. They're uint32_t and float, which your warning messages are also telling you: but argument 2 has type uint32_t [-Wformat] and but argument 3 has type float [-Wformat].
There's a number of solutions. The best would be to use the correct format specifier! (duh). That's "%d" for int, "%"PRIu32 for uint32_t and "%f" for double (which floats get promoted to). In the case of uint32_t, you could cast to an unsigned long and print using "%lu", instead.
Who is online
Users browsing this forum: No registered users and 1 guest
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
We also have a RTOS version and a MESH version too!
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!