CubeCell-Arduino icon indicating copy to clipboard operation
CubeCell-Arduino copied to clipboard

printf is broken

Open eiten opened this issue 5 years ago • 2 comments

Hello there. Printf is broken/not working for all format specifications. Sketch:

void setup() {
  Serial.begin(115200);
  Serial.printf("Unsigned char: %hhu, unsigned long: %hu", (uint8_t)123, (uint16_t)1234);
}

void loop() {
}

expected output (confirmed on your LoRa 32 ESP32 board): Unsigned char: 123, unsigned long: 1234 Output if compiling for and running on CubeCell board:

Unsigned char: hu, unsigned long: 123 Same wrong behaviour on Arduino IDE and platform.io.

Regards, Edi

eiten avatar Jul 29 '20 10:07 eiten

sorry, %hhu is no supported, the printted 123 is for (uint8_t)123, and (uint16_t)1234 is ignored

Heltec-Aaron-Lee avatar Aug 13 '20 07:08 Heltec-Aaron-Lee

Is the %f format for float or double supported?

float test_float = 45.6; Serial.printf("test_float is %f \n", test_float); results in some hex character being printed out.

Serial.print("test_float "); Serial.println(test_float); results in the proper output of 45.6 on the monitor display.

What format specifiers are supported for a printf?

DavidStacer avatar Jun 07 '21 15:06 DavidStacer