Skip to main content
added 213 characters in body
Source Link

I am trying to store and use a pointer to a global function. The function global_f returns a String and takes an object as parameter:

String global_f(Request r){
    // ...
    return "This is it";
}

I have also declared a type:

typedef String (*f_type)(Request);

And this is the class that stores the function:

class T {
    f_type f;

    void setF(f_type fFunc){ // called as: setF(&global_f)
        f = fFunc;
        f(Request());        // This Works
    }

    void callF(){
        f(Request());       // This Freezes the arduino
    }
}

So I can call f in the instructor, but it freezes the Arduino in other methods.

Follow-up: It runs in all methods, that the function is being passed as a parameter and stored in the object. This is where this functions is called in the actual code: GitHub

I am trying to store and use a pointer to a global function. The function global_f returns a String and takes an object as parameter:

String global_f(Request r){
    // ...
    return "This is it";
}

I have also declared a type:

typedef String (*f_type)(Request);

And this is the class that stores the function:

class T {
    f_type f;

    void setF(f_type fFunc){ // called as: setF(&global_f)
        f = fFunc;
        f(Request());        // This Works
    }

    void callF(){
        f(Request());       // This Freezes the arduino
    }
}

So I can call f in the instructor, but it freezes the Arduino in other methods.

Follow-up: It runs in all methods, that the function is being passed as a parameter and stored in the object.

I am trying to store and use a pointer to a global function. The function global_f returns a String and takes an object as parameter:

String global_f(Request r){
    // ...
    return "This is it";
}

I have also declared a type:

typedef String (*f_type)(Request);

And this is the class that stores the function:

class T {
    f_type f;

    void setF(f_type fFunc){ // called as: setF(&global_f)
        f = fFunc;
        f(Request());        // This Works
    }

    void callF(){
        f(Request());       // This Freezes the arduino
    }
}

So I can call f in the instructor, but it freezes the Arduino in other methods.

Follow-up: It runs in all methods, that the function is being passed as a parameter and stored in the object. This is where this functions is called in the actual code: GitHub

added 128 characters in body
Source Link

I am trying to store and use a pointer to a global function. The function global_f returns a String and takes an object as parameter:

String global_f(Request r){
    // ...
    return "This is it";
}

I have also declared a type:

typedef String (*f_type)(Request);

And this is the class that stores the function:

class T {
    f_type f;

    void TsetF(f_type fFunc){  // called as: TsetF(&global_f)
        f = fFunc;
        f(Request());        // This Works
    }

    void callF(){
        f(Request());       // This Freezes the arduino
    }
}

So I can call f in the instructor, but it freezes the Arduino in other methods.

Follow-up: It runs in all methods, that the function is being passed as a parameter and stored in the object.

I am trying to store and use a pointer to a global function. The function global_f returns a String and takes an object as parameter:

String global_f(Request r){
    // ...
    return "This is it";
}

I have also declared a type:

typedef String (*f_type)(Request);

And this is the class that stores the function:

class T {
    f_type f;

    void T(f_type fFunc){  // called as: T(&global_f)
        f = fFunc;
        f(Request());      // This Works
    }

    void callF(){
        f(Request());     // This Freezes the arduino
    }
}

So I can call f in the instructor, but it freezes the Arduino in other methods.

I am trying to store and use a pointer to a global function. The function global_f returns a String and takes an object as parameter:

String global_f(Request r){
    // ...
    return "This is it";
}

I have also declared a type:

typedef String (*f_type)(Request);

And this is the class that stores the function:

class T {
    f_type f;

    void setF(f_type fFunc){ // called as: setF(&global_f)
        f = fFunc;
        f(Request());        // This Works
    }

    void callF(){
        f(Request());       // This Freezes the arduino
    }
}

So I can call f in the instructor, but it freezes the Arduino in other methods.

Follow-up: It runs in all methods, that the function is being passed as a parameter and stored in the object.

edited body
Source Link
Michel Keijzers
  • 13k
  • 7
  • 42
  • 59

I am trying to store and use a pointer to a global function. The function global_f returns a String and takes an object as parameter:

String global_f(Request r){
    // ...
    return "This is it";
}

I have also declared a type:

typedef String (*f_type)(Request);

And this is the class that stores the function:

class T {
    f_type f;

    void T(f_type fFunc){  // called as: T(&global_f)
        f = fFunc;
        f(Request());      // This Works
    }

    void callF(){
        f(Request());     // This Freezes the arduino
    }
}

So iI can call f in the instructor, but it freezes the arduinoArduino in other methods.

I am trying to store and use a pointer to a global function. The function global_f returns a String and takes an object as parameter:

String global_f(Request r){
    // ...
    return "This is it";
}

I have also declared a type:

typedef String (*f_type)(Request);

And this is the class that stores the function:

class T {
    f_type f;

    void T(f_type fFunc){  // called as: T(&global_f)
        f = fFunc;
        f(Request());      // This Works
    }

    void callF(){
        f(Request());     // This Freezes the arduino
    }
}

So i can call f in the instructor, but it freezes the arduino in other methods.

I am trying to store and use a pointer to a global function. The function global_f returns a String and takes an object as parameter:

String global_f(Request r){
    // ...
    return "This is it";
}

I have also declared a type:

typedef String (*f_type)(Request);

And this is the class that stores the function:

class T {
    f_type f;

    void T(f_type fFunc){  // called as: T(&global_f)
        f = fFunc;
        f(Request());      // This Works
    }

    void callF(){
        f(Request());     // This Freezes the arduino
    }
}

So I can call f in the instructor, but it freezes the Arduino in other methods.

Source Link
Loading