there are 2 issues in the attached sketch.
NotImplemented demonstrates that Serial.printf, and sprintf do not support floats on Teensy 4. They do on Teensy 3.6.
Crash1 demonstrates that ostringstream will crash the Teensy 4 if passed a float. This works on Teensy 3.6
NotImplemented demonstrates that Serial.printf, and sprintf do not support floats on Teensy 4. They do on Teensy 3.6.
Crash1 demonstrates that ostringstream will crash the Teensy 4 if passed a float. This works on Teensy 3.6
Code:
#include <sstream>
#include <string>
void Crash1()
{
std::ostringstream s;
s << 3;
Serial.println("works fine.");
s << 4.5f;
Serial.println("will not get here 1.");
}
#include <stdio.h>
#define MAX_FLOAT 100
// On teensy 3.6 this was implemented. affects Serial.printf too
void NotImplemented()
{
char buf[MAX_FLOAT];
sprintf(buf, "%d", 3);
Serial.println((std::string("Expect something in this box [") + buf + "]").c_str());
sprintf(buf, "%f", 2.5f);
Serial.println((std::string("Expect something in this box [") + buf + "]").c_str());
Serial.printf("Expect something in this box [%f]\n", 2.5f);
}
void setup() {
Serial.begin(115200);
Serial.println("setup()");
}
void loop() {
NotImplemented();
//Crash1(); // Teensy 4 will crash hard if you uncomment this.
Serial.println("loop");
delay(10);
}