why when implement interrupt handler in qt give beolw error ? How to resolve it ?
-
@Qt-embedded-developer It looks like the interrupt handler takes an int32_t parameter.
Check the interrupt_handler_t data type.@jsulm
From the error message (aka void ()()) and from looking at definitions ofinterrupt_handler_ton the web I do not think that is so. It seems to betypedef void @far (*interrupt_handler_t)(void);This is beyond my expertise of C++ now, but is there a problem with passing a C++ member function here??
-
@jsulm
From the error message (aka void ()()) and from looking at definitions ofinterrupt_handler_ton the web I do not think that is so. It seems to betypedef void @far (*interrupt_handler_t)(void);This is beyond my expertise of C++ now, but is there a problem with passing a C++ member function here??
@JonB @Qt-embedded-developer I don't think a method can be used here as interrupt handler. @Qt-embedded-developer use a normal function and call your MainWindow there (also, it is strange that MainWindow handles interrupts).
-
@Qt-embedded-developer It looks like the interrupt handler takes an int32_t parameter.
Check the interrupt_handler_t data type.@jsulm said in why when implement interrupt handler in qt give beolw error ? How to resolve it ?:
interrupt_handler_t
This 3 thing is related to your question and my 2nd error.
1] in source.h
static interrupt_handler_t interrupt_handler;2] in source.c
typedef void (*interrupt_handler_t)(void) ;3] in source.c
int32_t ST25DV_GPO_interrupt_init(interrupt_handler_t fh) { pthread_t intr_thread; struct sched_param params; int ret; if(fh == NULL) { fprintf(stderr,"Handler is not set\r\n"); return ERR_PARAM; } interrupt_handler = fh; /* create a pthread to poll for interrupt */ ret = pthread_create(&intr_thread, NULL, ST25DV_GPO_pthread_func, NULL); if (ret) { fprintf(stderr, "Error: poll thread creation %d\r\n", ret); return ERR_IO; } /* Assign highest priority to polling thread */ params.sched_priority = sched_get_priority_max(SCHED_FIFO); ret = pthread_setschedparam(intr_thread, SCHED_FIFO, ¶ms); if (ret) { fprintf(stderr,"Error: assigning high priority to polling thread\r\n"); return ERR_IO; } return ERR_NONE; } -
@jsulm said in why when implement interrupt handler in qt give beolw error ? How to resolve it ?:
interrupt_handler_t
This 3 thing is related to your question and my 2nd error.
1] in source.h
static interrupt_handler_t interrupt_handler;2] in source.c
typedef void (*interrupt_handler_t)(void) ;3] in source.c
int32_t ST25DV_GPO_interrupt_init(interrupt_handler_t fh) { pthread_t intr_thread; struct sched_param params; int ret; if(fh == NULL) { fprintf(stderr,"Handler is not set\r\n"); return ERR_PARAM; } interrupt_handler = fh; /* create a pthread to poll for interrupt */ ret = pthread_create(&intr_thread, NULL, ST25DV_GPO_pthread_func, NULL); if (ret) { fprintf(stderr, "Error: poll thread creation %d\r\n", ret); return ERR_IO; } /* Assign highest priority to polling thread */ params.sched_priority = sched_get_priority_max(SCHED_FIFO); ret = pthread_setschedparam(intr_thread, SCHED_FIFO, ¶ms); if (ret) { fprintf(stderr,"Error: assigning high priority to polling thread\r\n"); return ERR_IO; } return ERR_NONE; }@Qt-embedded-developer said in why when implement interrupt handler in qt give beolw error ? How to resolve it ?:
typedef void (*interrupt_handler_t)(void) ;
This is a function pointer type, not a pointer to a method, so you can't use a method as interrupt handler. Use a normal function.
-
@Qt-embedded-developer said in why when implement interrupt handler in qt give beolw error ? How to resolve it ?:
typedef void (*interrupt_handler_t)(void) ;
This is a function pointer type, not a pointer to a method, so you can't use a method as interrupt handler. Use a normal function.
@jsulm said in why when implement interrupt handler in qt give beolw error ? How to resolve it ?:
This is a function pointer type, not a pointer to a method
This is kind of what I thought/asked you.
I am not familiar with this distinction between "a function pointer type" versus "a pointer to a method". Could you explain, or point me to a description, please?
EDIT
Ah, is this to do with class (non-static) method will need an instance and of course that is not appropriate here? -
@jsulm said in why when implement interrupt handler in qt give beolw error ? How to resolve it ?:
This is a function pointer type, not a pointer to a method
This is kind of what I thought/asked you.
I am not familiar with this distinction between "a function pointer type" versus "a pointer to a method". Could you explain, or point me to a description, please?
EDIT
Ah, is this to do with class (non-static) method will need an instance and of course that is not appropriate here? -
@jsulm said in why when implement interrupt handler in qt give beolw error ? How to resolve it ?:
This is a function pointer type, not a pointer to a method
This is kind of what I thought/asked you.
I am not familiar with this distinction between "a function pointer type" versus "a pointer to a method". Could you explain, or point me to a description, please?
EDIT
Ah, is this to do with class (non-static) method will need an instance and of course that is not appropriate here?@JonB said in why when implement interrupt handler in qt give beolw error ? How to resolve it ?:
Ah, is this to do with class (non-static) method will need an instance and of course that is not appropriate here?
Yes, you need an instance.
-
@JonB Well, method pointers are funny:
typedef void (MainWindow::*MethodPointer)(); MethodPointer p = &MainWindow::doSomething; // Calling (this->*p)();@jsulm
I did a Google and came up with https://isocpp.org/wiki/faq/pointers-to-members#fnptr-vs-memfnptr-typesIs the type of “pointer-to-member-function” different from “pointer-to-function”?
Yep.Consider the following function:
int f(char a, float b);
The type of this function is different depending on whether it is an ordinary function or a non-static member function of some class:Its type is “int ()(char,float)” if an ordinary function
Its type is “int (Fred::)(char,float)” if a non-static member function of class Fred
Note: if it’s a static member function of class Fred, its type is the same as if it were an ordinary function: “int (*)(char,float)”.Separately:
Yes, you need an instance.
Yes, that's kind of a different issue, in that it's not going to work anyway for the OP. But I was concentrating on the compiler error message.
-
@jsulm
I did a Google and came up with https://isocpp.org/wiki/faq/pointers-to-members#fnptr-vs-memfnptr-typesIs the type of “pointer-to-member-function” different from “pointer-to-function”?
Yep.Consider the following function:
int f(char a, float b);
The type of this function is different depending on whether it is an ordinary function or a non-static member function of some class:Its type is “int ()(char,float)” if an ordinary function
Its type is “int (Fred::)(char,float)” if a non-static member function of class Fred
Note: if it’s a static member function of class Fred, its type is the same as if it were an ordinary function: “int (*)(char,float)”.Separately:
Yes, you need an instance.
Yes, that's kind of a different issue, in that it's not going to work anyway for the OP. But I was concentrating on the compiler error message.
@JonB So How to implement the interrupt handler for any i2c device using qt ?
-
@JonB So How to implement the interrupt handler for any i2c device using qt ?
@Qt-embedded-developer Use a normal function as interrupt handler, not a method in a class. In that function you can then call methods of your class if you need to do so.