Good time dear ones.
For five hours I have been looking for how to fix the error, I can not understand what the point is.
There is something like this code:
float value = NAN;
....
different code, but the variable does not get a different value anywhere (the sensor is not connected)
....
char* rSensorItem::asString(const char* format, const float value)
{
if (isnan(value)) {
return malloc_stringf("\"%s\"", CONFIG_FORMAT_EMPTY);
} else {
return malloc_stringf(format, value);
};
}
where:
format = “%f”
char * malloc_stringf(const char *format, ...)
{
char*ret = nullptr;
if (format) {
// get the list of arguments
va_list args;
va_start(args, format);
// calculate length of resulting string
uint32_t len = vsnprintf(nullptr, 0, format, args);
// allocate memory for string
ret = (char*)malloc(len+1);
if (ret) {
memset(ret, 0, len+1);
vsnprintf(ret, len+1, format, args);
} else {
rlog_e(tagHEAP, "Out of memory!");
};
va_end(args);
};
return ret;
}
MCU crashes on line
uint32_t len = vsnprintf(nullptr, 0, format, args);
I know for sure that NaN is written in value, but (isnan(value)) for some reason does not catch it. I don’t understand anything anymore…