6 Replies Latest reply on Feb 24, 2017 9:59 AM by Intel Corporation

    Configuring Edison's power button handler

    PRigotti

      So I'm using Edison as a central module for an embedded project, communicating with an external MCU during a program that is set to run on boot.

       

      I'd like to change the behavior of the power button to call for a script that handles the program and some other things (like LED's) as well.
      I understand I can edit pwr-button-handler.c (and overwrite it's binary on Edison) and change the arguments I pass to it through the pwr-button-handler.service, however, I noticed I can't even get the default handle for a 3x press under a time interval of 4 seconds, which should call for a clean shutdown under "/bin/systemctl poweroff".

      I can print /dev/input/event1 while pressing the power button and get some "random" stuff, so I assume it should be working.

       

      Is the handler service being called at all?

       

      PS: Image version is 3.10.17.

        • 1. Re: Configuring Edison's power button handler
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hello PRigotti,

          Thank you for interest in the Intel® Edison Breakout Board.

          Could you please tell me if you are replacing the pwr_button_handler in the system service folder after editing and compiling the pwr-button-handler.c?

          Also, have you checked this thread https://communities.intel.com/message/266264#266264? In it, a customer shares his modified pwr-button-handler.c program, which adds the 3x press under 4 seconds for clean shutdown.  

          I’ll be waiting for your response.

          Regards,
          Andres V.

          • 2. Re: Configuring Edison's power button handler
            Intel Corporation
            This message was posted on behalf of Intel Corporation

            Hello PRigotti,

            I was wondering if you had the chance to check the suggestion provided.

            If you have any other question, don’t hesitate to contact us.

            Regards,
            Andres V.

            • 3. Re: Configuring Edison's power button handler
              PRigotti

              Hello Andres V.,

               

              Sorry for the delayed answer.

              I solved the issue by checking the status of the pwr-button-handler.service and noticing it was giving me a format error. I guess I messed up with the script lines while editing it with nano.
              The handler binary was successfully changed.

              Anyway, stupid mistake by me.

               

              I've created a few other services and there's a systemctl status output line that seems to be always present, stating: "[...] libmraa[186]: gpio214: init: Failed to write to ...e". What does that mean?

              • 4. Re: Configuring Edison's power button handler
                Intel Corporation
                This message was posted on behalf of Intel Corporation

                Hello PRigotti,

                I’m glad to hear that you could solve the issue.

                Thank you for sharing your experience, the community appreciates it.

                Regarding your question, does the output line seems to be associated with an issue you are experiencing? Or is it a question out of curiosity?
                I don’t recall seeing that message when programming/editing a service, perhaps you can attach visual aid, a specific procedure or a service example so I can’t try to replicate the message and try to help you understand what the output line means.

                I’ll be waiting for your response.

                Regards,
                Andres V.

                • 5. Re: Configuring Edison's power button handler
                  PRigotti

                  Hello Andres V.,

                   

                  I'm questioning it out of curiosity. The services have been running just fine.

                  I observed /usr/bin/blink-led exports and unexports gpio214. This script is also called in the original pwr-button-handler.service (which I have modified and currently only calls for the edited handler binary).

                  My main process is called on boot by another service and sets a few GPIO's with bash commands. I don't include MRAA anywhere in my source files, but the service still outputs the line about gpio214.

                  Maybe it could be related to any differences between the Arduino and the Mini Breakout boards?

                  Either way, everything's working as expected, so I'm not worried about it.

                   

                  Thank you for the support.

                  • 6. Re: Configuring Edison's power button handler
                    Intel Corporation
                    This message was posted on behalf of Intel Corporation

                    Hello PRigotti,

                     

                    I did some research regarding your question and you may be right, it seems to be associated with the process of creating or running a service. When the process can’t correctly identify whether you are using an Arduino Expansion Board or a Mini Breakout Board, it fails to initialize GPIO 214, hence the message.

                     

                    I hope that answers your question.

                     

                    Regards,
                    Andres V.