Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. why when implement interrupt handler in qt give beolw error ? How to resolve it ?
Qt 6.11 is out! See what's new in the release blog

why when implement interrupt handler in qt give beolw error ? How to resolve it ?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
16 Posts 3 Posters 2.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • jsulmJ jsulm

    @Qt-embedded-developer It looks like the interrupt handler takes an int32_t parameter.
    Check the interrupt_handler_t data type.

    JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by JonB
    #7

    @jsulm
    From the error message (aka void ()()) and from looking at definitions of interrupt_handler_t on the web I do not think that is so. It seems to be

    typedef 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??

    jsulmJ 1 Reply Last reply
    0
    • JonBJ JonB

      @jsulm
      From the error message (aka void ()()) and from looking at definitions of interrupt_handler_t on the web I do not think that is so. It seems to be

      typedef 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??

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #8

      @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).

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • jsulmJ jsulm

        @Qt-embedded-developer It looks like the interrupt handler takes an int32_t parameter.
        Check the interrupt_handler_t data type.

        Q Offline
        Q Offline
        Qt embedded developer
        wrote on last edited by
        #9

        @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, &params);
            if (ret) {
                fprintf(stderr,"Error: assigning high priority to polling thread\r\n");
                return ERR_IO;
            }
        
            return ERR_NONE;
        }
        
        jsulmJ 1 Reply Last reply
        0
        • Q Qt embedded developer

          @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, &params);
              if (ret) {
                  fprintf(stderr,"Error: assigning high priority to polling thread\r\n");
                  return ERR_IO;
              }
          
              return ERR_NONE;
          }
          
          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #10

          @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.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          JonBJ 1 Reply Last reply
          0
          • jsulmJ jsulm

            @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.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #11

            @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?

            jsulmJ 2 Replies Last reply
            0
            • JonBJ JonB

              @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?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by jsulm
              #12

              @JonB Well, method pointers are funny:

              typedef void (MainWindow::*MethodPointer)();
              MethodPointer p = &MainWindow::doSomething;
              // Calling
              (this->*p)();
              

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              JonBJ 1 Reply Last reply
              0
              • JonBJ JonB

                @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?

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #13

                @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.

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • jsulmJ jsulm

                  @JonB Well, method pointers are funny:

                  typedef void (MainWindow::*MethodPointer)();
                  MethodPointer p = &MainWindow::doSomething;
                  // Calling
                  (this->*p)();
                  
                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by JonB
                  #14

                  @jsulm
                  I did a Google and came up with https://isocpp.org/wiki/faq/pointers-to-members#fnptr-vs-memfnptr-types

                  Is 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.

                  Q 1 Reply Last reply
                  0
                  • JonBJ JonB

                    @jsulm
                    I did a Google and came up with https://isocpp.org/wiki/faq/pointers-to-members#fnptr-vs-memfnptr-types

                    Is 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.

                    Q Offline
                    Q Offline
                    Qt embedded developer
                    wrote on last edited by
                    #15

                    @JonB So How to implement the interrupt handler for any i2c device using qt ?

                    jsulmJ 1 Reply Last reply
                    0
                    • Q Qt embedded developer

                      @JonB So How to implement the interrupt handler for any i2c device using qt ?

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #16

                      @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.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      1

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved