8 Replies Latest reply on Jun 16, 2017 1:44 PM by Intel Corporation

    How to reboot Galileo Gen2 from java

    rahulmodi8812

      Hi There,

       

      While working on an IoT application I found a java code which reboot Arduino Uno. But I want to reboot Galileo Gen 2 board from java.

       

      Is there any class or method written which I can utilize in my application to reboot Galileo.

       

      Please find attached java file and refer "reboot()" method which reboots Arduino Uno.

       

      Regards

      Rahul Modi

        • 1. Re: How to reboot Galileo Gen2 from java
          FGT

          I think it would be easier to directly listen to a specific HTTP GET request to reboot the card.

           

          HTH,

           

          Fernando.

          • 2. Re: How to reboot Galileo Gen2 from java
            Intel Corporation
            This message was posted on behalf of Intel Corporation

            Hi rahulmodi8812,

            Do you still need assistance with this thread? We’ll be waiting for your response.

            -Sergio A
             

            • 3. Re: How to reboot Galileo Gen2 from java
              rahulmodi8812

              Yes, I need assistance on this.

              I just want a piece of java code which can reboot the Galileo.

               

              If I don't find, I will have to move to some alternative solution.

              • 4. Re: How to reboot Galileo Gen2 from java
                FGT

                rahulmodi8812 wrote:

                 

                Yes, I need assistance on this.

                I just want a piece of java code which can reboot the Galileo.

                 

                Connect your Intel Galileo to the LAN where you have your computer running (the one in which the java code is going to run and use

                /*********************************************************************/

                import java.io.*;

                public class javassh

                {

                  public static void main(String args[])

                  {

                    try

                    {

                      Process p=Runtime.getRuntime().exec("ssh root@<Intel.Galileo.IP.Here> reboot");

                      p.waitFor();

                 

                      BufferedReader reader=new BufferedReader(new InputStreamReader(p.getInputStream()));

                      String line=reader.readLine();

                      while (line!=null)

                      {

                        System.out.println(line);

                        line=reader.readLine();

                      }

                    }

                    catch(IOException e1) {}

                    catch(InterruptedException e2) {}

                 

                    System.out.println("Done");

                  }

                }

                /*********************************************************************/

                 

                Replace <Intel.Galileo.IP.Here> by your Intel Galileo Ethernet port IP

                 

                If I don't find, I will have to move to some alternative solution.

                 

                Did you think any?

                 

                HTH,

                 

                Fernando.

                • 5. Re: How to reboot Galileo Gen2 from java
                  Intel Corporation
                  This message was posted on behalf of Intel Corporation

                  Hi rahulmodi8812,

                  The simplest way I can think of to reboot your board with a Java code is using a system call. This method is practically the same as the one @FGT suggested. I found a few guides on how to do this, you can check this one for example: http://alvinalexander.com/java/edu/pj/pj010016 . In this guide, it is shown how to make a system call to the command “ps -ef”. The command in Linux to reboot is simply “reboot”, so the material on the guide can be easily replicated.

                  Hopefully this will give you an idea on how to implement system calls in your code.

                  Regards
                  -Sergio A
                   

                  • 6. Re: How to reboot Galileo Gen2 from java
                    FGT

                    An even simpler one...

                    /*********************************************************************/

                    import java.io.*;

                     

                    public class javassh2

                    {

                      public static void main(String args[])

                      {

                        try

                        {

                          Process p=Runtime.getRuntime().exec("ssh root@<Intel.Galileo.IP.Here> reboot");

                          p.waitFor();

                        }

                        catch(Exception e) {}

                     

                        System.out.println("Done");

                      }

                    }

                    /*********************************************************************/

                     

                    Replace <Intel.Galileo.IP.Here> by your Intel Galileo Ethernet port IP

                     

                    HTH,

                     

                    Fernando.

                    • 7. Re: How to reboot Galileo Gen2 from java
                      rahulmodi8812

                      Thanks Sergio and Fernando.

                       

                      I will try the solution provided by you.

                      • 8. Re: How to reboot Galileo Gen2 from java
                        Intel Corporation
                        This message was posted on behalf of Intel Corporation

                        You’re welcome. Let us know your results.

                        -Sergio A