Core resets itself when using strtod strtof atof? [solved]

Hi guys, I have this published spark function (below) which calls into the setParams hook.
Whenever this code tries to convert the string containing numbers which are larger than approx 70 to a float, the core resets itself. Smaller numbers work, but larger (more decimals) numbers like 100+ will crah it into reset.
Any idea what could be causing this?

int setParams(String args)
int res = -1;
char cmd[20];
args.toCharArray(cmd, 20);

char* str = strtok(cmd, "=");

if (strcmpi(str, "PID") == 0)
    str = strtok(NULL, ","); // P
    float kp = strtof(str, NULL);
    str = strtok(NULL, ","); // I
    float ki = strtof(str, NULL);
    str = strtok(NULL, ","); // D
    float kd = strtof(str, NULL); 
    waterPID.SetTunings(kp, ki, kd);
    sprintf(pidParams, "P:%f I:%f D:%f", kp, ki, kd);

    res = 1;

return res;
1 Like

Ok, it is now working again… seems to be a memory problem, I moved some variables outside the method and removed the sprintf … works just fine now…

I could do with afew Kb’s more :slight_smile:

1 Like