6 Replies Latest reply on May 12, 2015 5:44 PM by JPMontero_Intel

    methods to react on otg connection, in edison.

    juliday

      Hey all edisonions,

       

      I'm looking for methods to run a script on otg connection (J16).

      Quick thoughts, I might just build a crond-like daemon to monitor lsusb result, which wouldn't be graceful.

      Are there any better ideas? I think there're tons in linux professionals.

      Please help me with a bit of advice if you have anything.

       

      What I'd like to do in detail is this,

       

      1. I'll plug a USB Network interface on J16.

      2. Drivers will be loaded so it'll show something like followings on "ip a" command

      6: enp0s17u1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000

          link/ether 20:15:01:15:f1:67 brd ff:ff:ff:ff:ff:ff

      3. I want to run a script which will wake up enp0s17u1 and run udhcpc on it.

       

      Have a nice day!

      and thanks in advance!

       

      JooYoung.

        • 1. Re: methods to react on otg connection, in edison.
          Sandy_Intel

          Hi juliday,

           

          I moved your post to Edison Board support.

           

          Sincerely,

           

          Sandy

          • 2. Re: methods to react on otg connection, in edison.
            JPMontero_Intel

            Hi juliday,

             

            I suggest you to create a script with the commands you use in the terminal to set it up and then you can create a systemd service. Once you have a script you can create a service and place it inside /lib/system/system. I suggest you to check the services that are already in that folder, in here are a few examples as well. In the [Service] section you indicate the location of the script you want to execute with the command ExecStart=<filepath>. Once the service is ready you can start the service with the command systemctl start filename.service. In order to make it start at boot you have to use enable, the command would look like this systemctl enable filename.service. I hope you find this helpful.

             

            Regards,
            JPMontero_Intel

            • 3. Re: methods to react on otg connection, in edison.
              juliday

              Hey JPMontero,

               

              Thank you for Re.

              You're right, indeed I'm going to make the service for it in the end.

              But what I was asking was about any sort of 'EVENT' (or signal? in linux's case? I'm not an expert on linux) that is fired when I plug something into

              OTG(J16) port, or when any kmod's enabled.

               

              Or are you suggesting me to write a script to monitor what's changing every..

              for example, second, and register that script as a systemd service?

               

              Thanks again,

              JooYoung.

              • 4. Re: methods to react on otg connection, in edison.
                JPMontero_Intel

                juliday, you can detect if there is something connected to the OTG with the dmesg command. When you connect the microUSB cable you should see something like this:

                [  267.293510] pmic_ccsm pmic_ccsm: USB VBUS Detected. Notifying OTG driver
                [  268.439519] g_multi gadget: high-speed config #1: Multifunction with RNDIS

                Regards,
                JPMontero_Intel

                • 5. Re: methods to react on otg connection, in edison.
                  juliday

                  Thanks everytime JPMontero.

                   

                  So you're saying that I have to make a deamon to monitor dmesg?

                  I've been looking for a signal that can TRIGGER MY SCRIPT,

                  not MY SCRIPT'S PULLING INFORMATION TO BE TRIGGERED.

                  Please understand me If I wasn't clear enough. English's not my native tongue.

                   

                  JooYoung.

                  • 6. Re: methods to react on otg connection, in edison.
                    JPMontero_Intel

                    Hi juliday,

                     

                    Yes, that is one option. Another option would be to use lsusb –v which provides more information on the USB devices. You can also read the /proc/kmsg which provides messages from the kernel. You might also want to take a look at /proc/interrupts, but for all of these cases you would have to check the status in order to trigger your code. I hope you find this helpful.

                     

                    Regards,
                    JPMontero_Intel