Package cc.arduino.packages.ssh

Examples of cc.arduino.packages.ssh.SCP


      myHighLevelConsoleStream.println("ERROR: Network upload using programmer not supported");
      return false;
  }

  Session session = null;
  SCP scp = null;
  try {
      JSch jSch = new JSch();
      session = jSch.getSession(myUser, myHost, 22);

      session.setUserInfo(new NoInteractionUserInfo(myPassword));
      session.connect(30000);

      scp = new SCP(session);
      SSH ssh = new SSH(session);
      myHighLevelConsoleStream.println("Sending sketch " + hexFile + " to " + myHost);
      scpFiles(scp, hexFile);
      myHighLevelConsoleStream.println("Sketch is now on yun: /tmp/sketch.hex");

      // String additionalParams = verbose ? prefs.get("upload.params.verbose") : prefs.get("upload.params.quiet");
      String additionalParams = "";// Common.getBuildEnvironmentVariable(myProject, myCConf, ArduinoConst. upload.params.quiet, "");

      // not sure why but I need to swap err and out not to get red text
      PrintStream stderr = new PrintStream(myOutconsole);
      PrintStream stdout = new PrintStream(myErrconsole);

      myHighLevelConsoleStream.println("merge-sketch-with-bootloader.lua /tmp/sketch.hex");
      ret = ssh.execSyncCommand("merge-sketch-with-bootloader.lua /tmp/sketch.hex", stdout, stderr);
      myHighLevelConsoleStream.println("kill-bridge");
      ssh.execSyncCommand("kill-bridge", stdout, stderr);
      myHighLevelConsoleStream.println("run-avrdude /tmp/sketch.hex '" + additionalParams + "'");
      ret = ret && ssh.execSyncCommand("run-avrdude /tmp/sketch.hex '" + additionalParams + "'", stdout, stderr);

  } catch (JSchException e) {
      String message = e.getMessage();
      String errormessage = "";
      if ("Auth cancel".equals(message) || "Auth fail".equals(message)) {
    errormessage = new String("ERROR: Authentication failed ") + myHost;
    // TODO add to ask if if the user wants to remove the password
    PasswordManager.ErasePassword(myHost);
      }
      if (e.getMessage().contains("Connection refused")) {
    errormessage = new String("ERROR: Unable to connect to ") + myHost;
      }
      myHighLevelConsoleStream.println(errormessage);
      myHighLevelConsoleStream.println(message);

      return false;
  } catch (Exception e) {
      myHighLevelConsoleStream.println(e.getMessage());
      return false;
  } finally {
      if (scp != null) {
    try {
        scp.close();
    } catch (IOException e) {
        myHighLevelConsoleStream.println(e.getMessage());
        return false;
    }
      }
View Full Code Here

TOP

Related Classes of cc.arduino.packages.ssh.SCP

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.