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. Qt-creator problem: error: 'gpio26' was not declared in this scope
Qt 6.11 is out! See what's new in the release blog

Qt-creator problem: error: 'gpio26' was not declared in this scope

Scheduled Pinned Locked Moved Mobile and Embedded
16 Posts 4 Posters 10.0k Views 1 Watching
  • 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.
  • J Offline
    J Offline
    JoergSH
    wrote on last edited by
    #5

    Thank You very much.
    Works fine now !

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JoergSH
      wrote on last edited by
      #6

      One more question.
      The program needs to be root to access gpio. I think thats not the best way. How to change that?

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #7

        Hi,

        Depending on how the device presents itself, one possibility would be to change the group of the gpio device and add your user to that group

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • J Offline
          J Offline
          JoergSH
          wrote on last edited by
          #8

          I try that but did not realy works.
          I build a group 'hwuser'
          add the user to the group

          change the group with

          chgrp -R hwuser /sys/class

          with ls -l could see that it is done.

          but after reboot the group is root again.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #9

            I thought you were accessing the GPIO through a /dev device or does the sys fs entry point to a device ?

            Anyway, sys (like /dev in general) is generated dynamically so that method won't work.

            If you are indeed accessing a device that can be found in /dev, you could try to setup an udev rule that sets the group of that device.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tomma
              wrote on last edited by
              #10

              That is more Linux question than Qt specific. If your target Linux uses udev for device handling then you need to specify rules which states you want "hwuser" group for gpio. Example setting udev-rules for gpio in raspberry pi: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=9667

              1 Reply Last reply
              0
              • J Offline
                J Offline
                JoergSH
                wrote on last edited by
                #11

                Ok thanks to all.
                I figured out now.

                Thats works for me:
                sudo nano /etc/udev/rules.d/99-gpio.rules
                paste:
                SUBSYSTEM==”gpio”, ACTION==”add”, PROGRAM=”/bin/sh -c ‘chown -R [user]:[group] /sys%p’”
                PROGRAM=”/bin/sh -c ‘chown -R [user]:[group] /sys/class’”

                save and reboot

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #12

                  That might be a little too radical not to say that it's a security breach. Just modify the file you use not the entire tree

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    JoergSH
                    wrote on last edited by
                    #13

                    ok I will test that.

                    thx

                    1 Reply Last reply
                    0
                    • J Offline
                      J Offline
                      JoergSH
                      wrote on last edited by
                      #14

                      it is mysterious,
                      after reboot export gpio works fine but set direction fails.

                      the same again on root works fine.

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #15

                        Are you accessing several files ?

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • J Offline
                          J Offline
                          JoergSH
                          wrote on last edited by
                          #16

                          not sure what You mean.

                          thats the init of the gpio

                          gpio26 = new GPIOClass("26"); //create new GPIO object

                          gpio26->export_gpio(); //export GPIO26
                          
                          
                          gpio26->setdir_gpio("out"); //GPIO26 set to output
                          

                          the export works, I can see it after start program

                          i have made a button to set direction... thats works to

                          i have made button for export unexport and set direction.

                          thats works fine too

                          1 Reply Last reply
                          0

                          • Login

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