public boolean avrdude(Collection params) throws RunnerException {
    List commandDownloader = new ArrayList();
    commandDownloader.add("avrdude");

    // Point avrdude at its config file since it's in a non-standard location.
    if (Base.isMacOS()) {
      commandDownloader.add("-C" + "hardware/tools/avr/etc/avrdude.conf");
    } else if (Base.isWindows()) {
      String userdir = System.getProperty("user.dir") + File.separator;
      commandDownloader.add("-C" + userdir + "hardware/tools/avr/etc/avrdude.conf");
    } else {
      // ???: is it better to have Linux users install avrdude themselves, in
      // a way that it can find its own configuration file?
      commandDownloader.add("-C" + "hardware/tools/avrdude.conf");
    }

    if (Preferences.getBoolean("upload.verbose")) {
      commandDownloader.add("-v");
      commandDownloader.add("-v");
      commandDownloader.add("-v");
      commandDownloader.add("-v");
    } else {
      commandDownloader.add("-q");
      commandDownloader.add("-q");
    }
    // XXX: quick hack to chop the "atmega" off of "atmega8" and "atmega168",
    // then shove an "m" at the beginning.  won't work for attiny's, etc.
    commandDownloader.add(
        "-pm" + Preferences.get("boards." + Preferences.get("board") + ".build.mcu").substring(6));
    commandDownloader.addAll(params);

    return executeUploadCommand(commandDownloader);
  }
Exemplo n.º 2
0
  public Runner(JavaBuild build, RunnerListener listener) throws SketchException {
    this.listener = listener;
    //    this.sketch = sketch;
    this.build = build;

    if (listener instanceof Editor) {
      this.editor = (Editor) listener;
      sketchErr = editor.getConsole().getErr();
      sketchOut = editor.getConsole().getOut();
    } else {
      sketchErr = System.err;
      sketchOut = System.out;
    }

    // Make sure all the imported libraries will actually run with this setup.
    int bits = Base.getNativeBits();
    for (Library library : build.getImportedLibraries()) {
      if (!library.supportsArch(PApplet.platform, bits)) {
        sketchErr.println(library.getName() + " does not run in " + bits + "-bit mode.");
        int opposite = (bits == 32) ? 64 : 32;
        if (Base.isMacOS()) {
          // if (library.supportsArch(PConstants.MACOSX, opposite)) {  // should always be true
          throw new SketchException(
              "To use "
                  + library.getName()
                  + ", "
                  + "switch to "
                  + opposite
                  + "-bit mode in Preferences.");
          // }
        } else {
          throw new SketchException(
              library.getName()
                  + " is only compatible "
                  + "with the  "
                  + opposite
                  + "-bit download of Processing.");
          // throw new SketchException(library.getName() + " does not run in " + bits + "-bit
          // mode.");
          // "To use this library, switch to 32-bit mode in Preferences." (OS X)
          //  "To use this library, you must use the 32-bit version of Processing."
        }
      }
    }
  }
Exemplo n.º 3
0
  public long computeSize() throws RunnerException {
    String userdir = System.getProperty("user.dir") + File.separator;
    String avrBasePath;
    if (Base.isMacOS()) {
      avrBasePath = new String("tools/avr/bin/");
    } else if (Base.isLinux()) {
      avrBasePath = new String("");
    } else {
      avrBasePath = new String(userdir + "tools/avr/bin/");
    }
    String commandSize[] = new String[] {avrBasePath + "avr-size", " "};

    commandSize[1] = buildPath + File.separator + sketchName + ".hex";

    try {
      exception = null;
      size = -1;
      firstLine = null;
      Process process = Runtime.getRuntime().exec(commandSize);
      new MessageSiphon(process.getInputStream(), this);
      new MessageSiphon(process.getErrorStream(), this);
      boolean running = true;
      while (running) {
        try {
          process.waitFor();
          running = false;
        } catch (InterruptedException intExc) {
        }
      }
    } catch (Exception e) {
      exception = new RunnerException(e.toString());
    }

    if (exception != null) throw exception;

    if (size == -1) throw new RunnerException(firstLine);

    return size;
  }
Exemplo n.º 4
0
  protected String[] getMachineParams() {
    ArrayList<String> params = new ArrayList<String>();

    // params.add("-Xint"); // interpreted mode
    // params.add("-Xprof");  // profiler
    // params.add("-Xaprof");  // allocation profiler
    // params.add("-Xrunhprof:cpu=samples");  // old-style profiler

    // TODO change this to use run.args = true, run.args.0, run.args.1, etc.
    // so that spaces can be included in the arg names
    String options = Preferences.get("run.options");
    if (options.length() > 0) {
      String pieces[] = PApplet.split(options, ' ');
      for (int i = 0; i < pieces.length; i++) {
        String p = pieces[i].trim();
        if (p.length() > 0) {
          params.add(p);
        }
      }
    }

    //    params.add("-Djava.ext.dirs=nuffing");

    if (Preferences.getBoolean("run.options.memory")) {
      params.add("-Xms" + Preferences.get("run.options.memory.initial") + "m");
      params.add("-Xmx" + Preferences.get("run.options.memory.maximum") + "m");
    }

    if (Base.isMacOS()) {
      params.add("-Xdock:name=" + build.getSketchClassName());
      //      params.add("-Dcom.apple.mrj.application.apple.menu.about.name=" +
      //                 sketch.getMainClassName());
    }
    // sketch.libraryPath might be ""
    // librariesClassPath will always have sep char prepended
    params.add(
        "-Djava.library.path="
            + build.getJavaLibraryPath()
            + File.pathSeparator
            + System.getProperty("java.library.path"));

    params.add("-cp");
    params.add(build.getClassPath());
    //    params.add(sketch.getClassPath() +
    //        File.pathSeparator +
    //        Base.librariesClassPath);

    // enable assertions
    // http://dev.processing.org/bugs/show_bug.cgi?id=1188
    params.add("-ea");
    // PApplet.println(PApplet.split(sketch.classPath, ':'));

    String outgoing[] = new String[params.size()];
    params.toArray(outgoing);

    //    PApplet.println(outgoing);
    //    PApplet.println(PApplet.split(outgoing[0], ":"));
    //    PApplet.println();
    //    PApplet.println("class path");
    //    PApplet.println(PApplet.split(outgoing[2], ":"));

    return outgoing;
    // return (String[]) params.toArray();

    //  System.out.println("sketch class path");
    //  PApplet.println(PApplet.split(sketch.classPath, ';'));
    //  System.out.println();
    //  System.out.println("libraries class path");
    //  PApplet.println(PApplet.split(Base.librariesClassPath, ';'));
    //  System.out.println();
  }