Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8772139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:58:03+00:00 2026-06-13T17:58:03+00:00

I am writing a program to control a auto home brewing system on an

  • 0

I am writing a program to control a auto home brewing system on an Arduino Mega micro controller (written in C/C++). In short, what the program is doing is there is a C# application which periodically sends messages through USB to the micro controller. There is then a messaging interface which I wrote which reads the message, and forwards it to whichever component the message is for. Each message is 16 bytes long, the first 4 is a transaction code, and the last 12 is for data. Now, I read in the message and forward to it to my StateController class. It comes in from the InboundMessage function. What I am trying to do is I have a struct (defined in StateController.h) which contains the transaction code and pointer to a member function within StateController. I defined a QueueList (just a simple linked list library), and pushed a bunch of these structs into it. What I would like to do is then when a message comes into the inboundMessage function, i would like to loop through the linked list until I find a transaction code which matches, and then call the member function which is for that message, passing it the data in the message.

I think I have everything initialized correctly, but here is the problem. When I try and compile I get an error saying “func does not exist in this scope”. I have looked all over for a solution to this, but can not find one. My codes is below

StateController.cpp

StateController::StateController(){
  currentState = Idle;
  prevState = Idle;
  lastRunState = Idle;

  txnTable.push((txnRow){MSG_BURN, &StateController::BURNprocessor});
  txnTable.push((txnRow){MSG_MANE, &StateController::MANEprocessor});
  txnTable.push((txnRow){MSG_MAND, &StateController::MANDprocessor});
  txnTable.push((txnRow){MSG_PUMP, &StateController::PUMPprocessor});
  txnTable.push((txnRow){MSG_STAT, &StateController::STATprocessor});  
  txnTable.push((txnRow){MSG_SYNC, &StateController::SYNCprocessor});
  txnTable.push((txnRow){MSG_VALV, &StateController::VALVprocessor});
}

void StateController::inboundMessage(GenericMessage msg){
  // Read transaction code and do what needs to be done for it

  for (int x = 0; x < txnTable.count(); x++)
  {
    if (compareCharArr(msg.code, txnTable[x].code, TXN_CODE_LEN) == true)
    {
      (txnTable[x].*func)(msg.data);
      break;
    }
  }
}

StateController.h

class StateController{
  // Public functions
  public:

    // Constructor
    StateController();

    // State Controller message handeler
    void inboundMessage(GenericMessage msg);

    // Main state machine
    void doWork();

  // Private Members
  private:  

    // Hardware interface
    HardwareInterface hardwareIntf;

    // Current state holder
    StateControllerStates currentState;

    // Preveous State
    StateControllerStates prevState;

    // Last run state
    StateControllerStates lastRunState;

    // BURN Message Processor
    void BURNprocessor(char data[]);

    // MANE Message Processor
    void MANEprocessor(char data[]);

    // MAND Message Processor
    void MANDprocessor(char data[]);

    // PUMP Message Processor
    void PUMPprocessor(char data[]);

    //STAT Message Processor
    void STATprocessor(char data[]);

    // SYNC Message Processor
    void SYNCprocessor(char data[]);

    // VALV Message Processor
    void VALVprocessor(char data[]);

    void primePumps();

    // Check the value of two sensors given the window
    int checkSensorWindow(int newSensor, int prevSensor, int window);

    struct txnRow{
    char code[TXN_CODE_LEN + 1];
    void (StateController::*func)(char[]);
    };

    QueueList<txnRow> txnTable;

};

Any idea what is wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:58:05+00:00Added an answer on June 13, 2026 at 5:58 pm

    func is just a normal member of txnRow so you access it with ., not .*, e.g. txnTable[x].func.

    To call this member function on, say, this, you would do something like:

    (this->*(txnTable[x].func))(msg.data);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an access control program in Java that captures passwords using JPasswordField
I am writing a program to control a flashbulb. The flash fires in response
I am writing a program in VS 2005 and I wanna control the access
I'm writing a c# application which uses automation to control another program. Naturally that
I am writing a program to control an Iridium modem that communicates with a
I am currently writing a remote control program to control a robot on all
I am writing a C program to control an ARDrone, and would like the
I am writing a small Bluetooth-based serial control program to talk to a serial
I'm writing a program that needs to take input from an XBox 360 controller.
I'm writing a custom control for a program. The control has a ComboBox in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.