1 2 Previous Next 17 Replies Latest reply on Nov 25, 2014 6:31 AM by deium

    Application Running On Powerup

    jblackston

      How do I set an application to run automatically once the Edison is powered up?

        • 1. Re: Application Running On Powerup
          mhahn

          I think this has been discussed in this forum in other threads: you would want to write systemd service files

          • 2. Re: Application Running On Powerup
            jblackston

            I got it up and running but the issue I'm having is network connections. It's kind of weird. The application I have sends a UDP announcement once it starts to run. When the Edison is connected to a client network everything seems to work find. But when I set the Edison up as an AP and connect to it via my laptop the UDP announcement packets are not transmitting. I started out with the service 'After' option set to 'network.target' and then tried 'network.open.target' and nothing seems to matter. What setting is needed for the software to run under AP conditions?

            • 3. Re: Application Running On Powerup
              mhahn

              "problem" with network target: when is the network up?

              After "network.target" doesn't mean you do have full internet access. And as systemd is by design deserialized you'll never know exactly the order service files will get started.

              what you can do e.g. is to have your binary been restarted if it's not successful. You can schedule it for some sec later to give the network some time to fully start.

              • 4. Re: Application Running On Powerup
                mmi

                You can also try to replace "network.target" by "network.service". I do so on my Archlinux pc's and it works fine.

                • 5. Re: Application Running On Powerup
                  mhahn

                  Good catch - however, AFAIK you still don't have a guarantee that the network is up to the extent you'd expect,   e.g. you might not be able to ping an external ip right away but would have to wait till your network manager is done

                  • 6. Re: Application Running On Powerup
                    jblackston

                    What I'm looking for I guess is not so much the network being up, but the IP and all of that stuff being assigned. The software when launches will start broadcasting a UDP port, but of course it needs to open up the socket. For some reason it seems like when I connect to a client it is occurring fast enough to which the software has everything it needs to function properly. When it's setup as AP mode it seems like for some reason maybe the network settings haven't completed when the software starts to run. I've created a version of the software to check to see if it's successfully created a socket and to keep trying till it does all while logging the status. In both cases running as a AP or connected to a Client Network I get the same results so I'm not totally sure what is going on.

                    • 7. Re: Application Running On Powerup
                      jblackston

                      Is there a way to tell when the OS has successfully connected to a network, or setup a network? First off I would like to know this so that I could possibly turn an LED on to tell the users that when they setup the client network it worked and we are now on... Also I could use this as possibly a way to then launch my application.

                      • 8. Re: Application Running On Powerup
                        deium

                        jblackston In following mhahn and mmi line of suggestions,

                        I might be inclined to include a loop (sudo-code below) that holds the rest of your routines in pattern until it has been successful

                        then you know your network is up and your code continues onward.

                        setup_upd_stuff {

                          desired_result = a_known_good_value

                        }

                         

                        function attempt_ping() {

                          // attempt your ping

                          // catch any exceptions so program does not exit

                          return ping_result

                        }

                         

                        pinged_successfully = false;

                        repeat

                          if (attempt_ping = desired_result) then

                            pinged_successfully = true;

                        until pinged_successfully;

                        ... program continues on after success.

                         

                        // checking if your IP has been assigned with System('ifconfig > ipcheck.log') --> check log created

                        • 9. Re: Application Running On Powerup
                          AlexT_Intel

                          Another one would be to try and see if there's any other systemd, more relevant to this context, service, to which you can set your service to depend upon. How exactly do you configure it in the AP mode?

                          • 10. Re: Application Running On Powerup
                            deium

                            in mhahn's comment #3, we can't truly depend that they execute and complete in sequence.

                            • 11. Re: Application Running On Powerup
                              AlexT_Intel

                              Well, that's true, but what's also true is that you can specify dependencies on other services and then we do have a guarantee one doesn't start earlier then the other.

                               

                              So if there's a service, say timesyncd - which uses network - which is also needed for the application in question, in addition to the bare network service, then we could try setting the dependency to that service, not to the network one - that's what I'm trying to describe here.

                              • 12. Re: Application Running On Powerup
                                jblackston

                                Ok, I'll look into that and check try the timesyncd and see how that works out... I tried the step in deium's comment in my code but i found that it seemed to function the same when the software ran connecting to a client. It didn't seem to show that there was an IP failure in the log I generated for the application. This almost goes in the same idea of how do these embedded systems that run Linux turn on a LED to signify to the customer that it's successfully connected to a network (or created a AP).

                                • 13. Re: Application Running On Powerup
                                  deium

                                  if that code was implemented properly, the code would be in a continuous loop until you had a successful ping, then continuing onward to your desired routine.

                                  So if that wasn't the case, it wasn't coded correctly.

                                  • 14. Re: Application Running On Powerup
                                    jblackston

                                    What am I suppose to setup the ping, because how do I get the software to know if the device is connecting to a client or AP? I would assume when I ping the IP address I'm pinging would depend which connection is taking place. Or am I miss understanding your idea of implementation?

                                    1 2 Previous Next