I have a problem using sigaction in C++ with this class:
class SerialHandler{
private:
...
/* Action Handling */
struct sigaction receive_handler;
/* Called using the receive_handler*/
static void receive_function(int status);
/* Get byte from the Serial Port */
unsigned char receive_byte();
/* Buffer for Singalinterrupt on Reciving */
std::vector<char> in_char_buffer;
...
};
I really need to use an Interrupt and really need to use a member function (receive_function) on the Interrupt/Sigaction, because I need access to a member variable (vector in_char_buffer). Problem: You can't use member function using sigaction because you have to pass a normal function to the sigaction.sa_handler.
As you can see using a static
function isn't an alternative either, because you would not be able to get access to the member variable. Also a wrapper would not help. You would access to an new object but not to the specific one.
So is there an alternative that can handle this problem?