Example #1
1
  public void run() {

    while (remainingJobs() > 0) {

      Object input = null;

      synchronized (pool) {
        while (pool.isEmpty()) {
          if (remainingJobs() == 0) {
            return;
          }
          try {
            pool.wait();
          } catch (InterruptedException e) {
          }
        }

        input = pool.remove(pool.size() - 1);

        process(input);
        jobsDone++;
      }
      // end if
    }
    // end while
  }
  public ASTNode rewriteTo() {
    // Declared in VariableDeclaration.jrag at line 124
    if (getNumVariableDecl() == 1) {
      state().duringVariableDeclaration++;
      ASTNode result = rewriteRule0();
      state().duringVariableDeclaration--;
      return result;
    }

    // Declared in VariableDeclaration.jrag at line 135
    if (getParent().getParent() instanceof TypeDecl
        && ((TypeDecl) getParent().getParent()).getBodyDeclListNoTransform() == getParent()
        && getNumVariableDecl() > 1) {
      state().duringVariableDeclaration++;
      List list = (List) getParent();
      int i = list.getIndexOfChild(this);
      List newList = rewriteTypeDecl_getBodyDecl();
      for (int j = 1; j < newList.getNumChildNoTransform(); j++)
        list.insertChild(newList.getChildNoTransform(j), ++i);
      state().duringVariableDeclaration--;
      return newList.getChildNoTransform(0);
    }
    return super.rewriteTo();
  }
  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);
  }
 public void addTypeArgument(Access node) {
   List<Access> list =
       (parent == null || state == null)
           ? getTypeArgumentListNoTransform()
           : getTypeArgumentList();
   list.addChild(node);
 }
Example #5
0
    public MetadataBlob[] select(String selectString) {
      PreparedStatement stmt = null;
      try {
        stmt =
            conn.prepareStatement(
                "select writingKey, mapkey, blobdata from metadatablobs " + selectString + ";");
        ResultSet rs = stmt.executeQuery();
        List<MetadataBlob> list = new ArrayList<MetadataBlob>();
        while (rs.next()) {
          MetadataBlob f =
              new MetadataBlob(
                  rs.getString("writingkey"), rs.getString("mapkey"), rs.getString("blobdata"));
          list.add(f);
        }

        return list.toArray(new MetadataBlob[0]);
      } catch (SQLException sqe) {
        System.err.println("Error selecting: " + selectString);
        sqe.printStackTrace();
        return null;
      } finally {
        if (stmt != null)
          try {
            stmt.close();
          } catch (SQLException sqe2) {
            sqe2.printStackTrace();
          }
      }
    }
 /**
  * Add element to list SuperInterfaceIdList
  *
  * @apilevel high-level
  * @ast method
  * @declaredat java.ast:27
  */
 public void addSuperInterfaceId(Access node) {
   List<Access> list =
       (parent == null || state == null)
           ? getSuperInterfaceIdListNoTransform()
           : getSuperInterfaceIdList();
   list.addChild(node);
 }
 public void addVariableDecl(VariableDecl node) {
   List<VariableDecl> list =
       (parent == null || state == null)
           ? getVariableDeclListNoTransform()
           : getVariableDeclList();
   list.addChild(node);
 }
Example #8
0
  /*
  	-- This is a helper methid to run the morph files
  */
  private static void runMorphDataSet() throws Exception {

    String morph_directory =
        "../../thesis-datasets/morph/"; // directory where all the morph code is stored
    File d = new File(morph_directory);
    // get all the files from a directory
    File[] fList = d.listFiles();
    List<String> dir_list = new ArrayList<String>();
    for (File file : fList) {
      if (file.isDirectory()) {
        dir_list.add(file.getName());
      }
    }
    for (String dir : dir_list) {
      directory = morph_directory + dir + "/";
      System.out.println("Running TDDD " + directory);
      ReadFile.readFile(directory, fileList); // read the two files
      System.out.println(fileList.get(0) + " " + fileList.get(1));
      preliminaryStep(directory);
      startCDC();
      fileList.clear();
      fileArray.clear();
      hashed_File_List.clear();
    }
  }
  @SuppressWarnings("squid:S1244")
  private static String selectBestEncoding(String acceptEncodingHeader) {
    // multiple encodings are accepted; determine best one

    Collection<String> bestEncodings = new HashSet<>(3);
    double bestQ = 0.0;
    Collection<String> unacceptableEncodings = new HashSet<>(3);
    boolean willAcceptAnything = false;

    for (String token : COMMA.split(acceptEncodingHeader)) {
      ContentEncodingQ contentEncodingQ = parseContentEncodingQ(token);
      String contentEncoding = contentEncodingQ.getContentEncoding();
      double q = contentEncodingQ.getQ();
      if (ANY_ENCODING.equals(contentEncoding)) {
        willAcceptAnything = q > 0.0;
      } else if (SUPPORTED_ENCODINGS.contains(contentEncoding)) {
        if (q > 0.0) {
          // This is a header quality comparison.
          // So it is safe to suppress warning squid:S1244
          if (q == bestQ) {
            bestEncodings.add(contentEncoding);
          } else if (q > bestQ) {
            bestQ = q;
            bestEncodings.clear();
            bestEncodings.add(contentEncoding);
          }
        } else {
          unacceptableEncodings.add(contentEncoding);
        }
      }
    }

    if (bestEncodings.isEmpty()) {
      // nothing was acceptable to us
      if (willAcceptAnything) {
        if (unacceptableEncodings.isEmpty()) {
          return SUPPORTED_ENCODINGS.get(0);
        } else {
          for (String encoding : SUPPORTED_ENCODINGS) {
            if (!unacceptableEncodings.contains(encoding)) {
              return encoding;
            }
          }
        }
      }
    } else {
      for (String encoding : SUPPORTED_ENCODINGS) {
        if (bestEncodings.contains(encoding)) {
          return encoding;
        }
      }
    }

    return NO_ENCODING;
  }
Example #10
0
 private List createVariableDeclarationList() {
   List varList = new List();
   for (int j = 0; j < getNumVariableDecl(); j++) {
     VariableDeclaration v =
         getVariableDecl(j)
             .createVariableDeclarationFrom(
                 (Modifiers) getModifiers().fullCopy(), (Access) getTypeAccess().fullCopy());
     if (j == 0) v.setStart(start);
     varList.add(v);
   }
   return varList;
 }
 private static String parseBestEncoding(String acceptEncodingHeader) {
   ContentEncodingQ contentEncodingQ = parseContentEncodingQ(acceptEncodingHeader);
   String contentEncoding = contentEncodingQ.getContentEncoding();
   if (contentEncodingQ.getQ() > 0.0) {
     if (ANY_ENCODING.equals(contentEncoding)) {
       return SUPPORTED_ENCODINGS.get(0);
     } else if (SUPPORTED_ENCODINGS.contains(contentEncoding)) {
       return contentEncoding;
     }
   }
   return NO_ENCODING;
 }
Example #12
0
 @Override
 public Iterable<DataKey> getSubKeys() {
   final Tag tag = this.findLastTag(this.path, false);
   if (!(tag instanceof CompoundTag)) {
     return (Iterable<DataKey>) Collections.emptyList();
   }
   final List<DataKey> subKeys = (List<DataKey>) Lists.newArrayList();
   for (final String name : ((CompoundTag) tag).getValue().keySet()) {
     subKeys.add(new NBTKey(this.createRelativeKey(name)));
   }
   return subKeys;
 }
 public static void main(String[] args) throws Exception {
   int iterations = 0;
   File zFile1 = new File(System.getProperty("test.src", "."), "pkware123456789012345.zip");
   while (iterations < 2500) {
     ZipFile zipFile = new ZipFile(zFile1);
     List entries = Collections.list(zipFile.entries());
     for (Iterator it = entries.iterator(); it.hasNext(); ) {
       ZipEntry zipEntry = (ZipEntry) it.next();
       InputStream in = zipFile.getInputStream(zipEntry);
       in.close();
     }
     iterations++;
   }
 }
Example #14
0
 /**
  * We have just received the final chunk of data for a file upload. Complete the transfer by
  * moving the uploaded content into the workspace.
  *
  * @throws IOException
  */
 private void completeTransfer(HttpServletRequest req, HttpServletResponse resp)
     throws ServletException, IOException {
   List<String> options = getOptions();
   boolean success;
   if (!options.contains("raw")) { // $NON-NLS-1$
     success = completeUnzip(req, resp);
   } else {
     success = completeMove(req, resp);
   }
   if (success) {
     resp.setHeader(ProtocolConstants.HEADER_LOCATION, "/file" + getPath()); // $NON-NLS-1$
     resp.setStatus(HttpServletResponse.SC_CREATED);
     resp.setContentType(ProtocolConstants.CONTENT_TYPE_HTML);
   }
 }
Example #15
0
  private List<File> compileFiles(String avrBasePath,
                                  String buildPath, List<File> includePaths,
                                  List<File> sSources, 
                                  List<File> cSources, List<File> cppSources,
                                  Map<String, String> boardPreferences)
    throws RunnerException {

    List<File> objectPaths = new ArrayList<File>();
    
    for (File file : sSources) {
      String objectPath = buildPath + File.separator + file.getName() + ".o";
      objectPaths.add(new File(objectPath));
      execAsynchronously(getCommandCompilerS(avrBasePath, includePaths,
                                             file.getAbsolutePath(),
                                             objectPath,
                                             boardPreferences));
    }
 		
    for (File file : cSources) {
        String objectPath = buildPath + File.separator + file.getName() + ".o";
        String dependPath = buildPath + File.separator + file.getName() + ".d";
        File objectFile = new File(objectPath);
        File dependFile = new File(dependPath);
        objectPaths.add(objectFile);
        if (is_already_compiled(file, objectFile, dependFile, boardPreferences)) continue;
        execAsynchronously(getCommandCompilerC(avrBasePath, includePaths,
                                               file.getAbsolutePath(),
                                               objectPath,
                                               boardPreferences));
    }

    for (File file : cppSources) {
        String objectPath = buildPath + File.separator + file.getName() + ".o";
        String dependPath = buildPath + File.separator + file.getName() + ".d";
        File objectFile = new File(objectPath);
        File dependFile = new File(dependPath);
        objectPaths.add(objectFile);
        if (is_already_compiled(file, objectFile, dependFile, boardPreferences)) continue;
        execAsynchronously(getCommandCompilerCPP(avrBasePath, includePaths,
                                                 file.getAbsolutePath(),
                                                 objectPath,
                                                 boardPreferences));
    }
    
    return objectPaths;
  }
Example #16
0
  /** Generates class index file for the specified root jar file. */
  void genIndex(String rootjar, String[] files) throws IOException {
    List<String> jars = getJarPath(rootjar);
    int njars = jars.size();
    String[] jarfiles;

    if (njars == 1 && files != null) {
      // no class-path attribute defined in rootjar, will
      // use command line specified list of jars
      for (int i = 0; i < files.length; i++) {
        jars.addAll(getJarPath(files[i]));
      }
      njars = jars.size();
    }
    jarfiles = jars.toArray(new String[njars]);
    JarIndex index = new JarIndex(jarfiles);
    dumpIndex(rootjar, index);
  }
Example #17
0
  static private List getCommandCompilerCPP(String avrBasePath,
    List includePaths, String sourceName, String objectName,
    Map<String, String> boardPreferences) {
    
    List baseCommandCompilerCPP = new ArrayList(Arrays.asList(new String[] {
      avrBasePath + "avr-g++",
      "-c", // compile, don't link
      "-g", // include debugging info (so errors include line numbers)
      "-Os", // optimize for size
      Preferences.getBoolean("build.verbose") ? "-Wall" : "-w", // show warnings if verbose
      "-fno-exceptions",
      "-ffunction-sections", // place each function in its own section
      "-fdata-sections",
      "-mmcu=" + boardPreferences.get("build.mcu"),
      "-DF_CPU=" + boardPreferences.get("build.f_cpu"),
      "-MMD", // output dependancy info
      "-DUSB_VID=" + boardPreferences.get("build.vid"),
      "-DUSB_PID=" + boardPreferences.get("build.pid"),      
      "-DARDUINO=" + Base.REVISION,
    }));

    for (int i = 0; i < includePaths.size(); i++) {
      baseCommandCompilerCPP.add("-I" + (String) includePaths.get(i));
    }

    baseCommandCompilerCPP.add(sourceName);
    baseCommandCompilerCPP.add("-o");
    baseCommandCompilerCPP.add(objectName);

    return baseCommandCompilerCPP;
  }
  /**
   * Finds all files in folder and in it's sub-tree of specified depth.
   *
   * @param file Starting folder
   * @param maxDepth Depth of the tree. If 1 - just look in the folder, no sub-folders.
   * @param filter file filter.
   * @return List of found files.
   */
  public static List<VisorLogFile> fileTree(File file, int maxDepth, @Nullable FileFilter filter) {
    if (file.isDirectory()) {
      File[] files = (filter == null) ? file.listFiles() : file.listFiles(filter);

      if (files == null) return Collections.emptyList();

      List<VisorLogFile> res = new ArrayList<>(files.length);

      for (File f : files) {
        if (f.isFile() && f.length() > 0) res.add(new VisorLogFile(f));
        else if (maxDepth > 1) res.addAll(fileTree(f, maxDepth - 1, filter));
      }

      return res;
    }

    return F.asList(new VisorLogFile(file));
  }
 // Declared in VariableDeclaration.jrag at line 135
 private List rewriteTypeDecl_getBodyDecl() {
   {
     List varList = new List();
     for (int j = 0; j < getNumVariableDecl(); j++) {
       FieldDeclaration f =
           getVariableDecl(j)
               .createFieldDeclarationFrom(
                   (Modifiers) getModifiers().fullCopy(), (Access) getTypeAccess().fullCopy());
       if (j == 0) f.setStart(start);
       else {
         f.getModifiersNoTransform().clearLocations();
         f.getTypeAccessNoTransform().clearLocations();
       }
       f.setFieldDecl(this);
       varList.add(f);
     }
     return varList;
   }
 }
Example #20
0
  @Override
  public byte[] getAllUsernamesGzip() throws IOException {
    try (PreparedStatement stmt = conn.prepareStatement("select name from users")) {
      ResultSet rs = stmt.executeQuery();
      List<String> list = new ArrayList<>();
      while (rs.next()) {
        String username = rs.getString("name");
        list.add(username);
      }

      ByteArrayOutputStream bout = new ByteArrayOutputStream();
      try (DataOutputStream dout = new DataOutputStream(new GZIPOutputStream(bout))) {

        for (String uname : list) Serialize.serialize(uname, dout);
      }
      return bout.toByteArray();
    } catch (SQLException sqe) {
      throw new IOException(sqe);
    }
  }
Example #21
0
  /**
   * Writes the index file out to <code>jos</code>. <code>oldEntries</code> gives the names of the
   * files that were removed, <code>movedMap</code> maps from the new name to the old name.
   */
  private static void createIndex(JarOutputStream jos, List oldEntries, Map movedMap)
      throws IOException {
    StringWriter writer = new StringWriter();

    writer.write(VERSION_HEADER);
    writer.write("\r\n");

    // Write out entries that have been removed
    for (int counter = 0; counter < oldEntries.size(); counter++) {
      String name = (String) oldEntries.get(counter);

      writer.write(REMOVE_COMMAND);
      writer.write(" ");
      writeEscapedString(writer, name);
      writer.write("\r\n");
    }

    // And those that have moved
    Iterator names = movedMap.keySet().iterator();

    if (names != null) {
      while (names.hasNext()) {
        String newName = (String) names.next();
        String oldName = (String) movedMap.get(newName);

        writer.write(MOVE_COMMAND);
        writer.write(" ");
        writeEscapedString(writer, oldName);
        writer.write(" ");
        writeEscapedString(writer, newName);
        writer.write("\r\n");
      }
    }

    JarEntry je = new JarEntry(INDEX_NAME);
    byte[] bytes = writer.toString().getBytes("UTF-8");

    writer.close();
    jos.putNextEntry(je);
    jos.write(bytes, 0, bytes.length);
  }
 static {
   List<String> temp = new ArrayList<>(6);
   temp.add(GZIP_ENCODING);
   temp.add(DEFLATE_ENCODING);
   temp.add(COMPRESS_ENCODING);
   temp.add(X_GZIP_ENCODING);
   temp.add(X_COMPRESS_ENCODING);
   temp.add(NO_ENCODING);
   SUPPORTED_ENCODINGS = Collections.unmodifiableList(temp);
 }
Example #23
0
    private void index() throws IOException {
      Enumeration entries = _jar.entries();

      _nameToEntryMap = new HashMap();
      _crcToEntryMap = new HashMap();

      _entries = new ArrayList();
      if (_debug) {
        System.out.println("indexing: " + _jar.getName());
      }
      if (entries != null) {
        while (entries.hasMoreElements()) {
          JarEntry entry = (JarEntry) entries.nextElement();

          long crc = entry.getCrc();

          Long crcL = new Long(crc);

          if (_debug) {
            System.out.println("\t" + entry.getName() + " CRC " + crc);
          }

          _nameToEntryMap.put(entry.getName(), entry);
          _entries.add(entry);

          // generate the CRC to entries map
          if (_crcToEntryMap.containsKey(crcL)) {
            // key exist, add the entry to the correcponding
            // linked list

            // get the linked list
            LinkedList ll = (LinkedList) _crcToEntryMap.get(crcL);

            // put in the new entry
            ll.add(entry);

            // put it back in the hash map
            _crcToEntryMap.put(crcL, ll);
          } else {
            // create a new entry in the hashmap for the new key

            // first create the linked list and put in the new
            // entry
            LinkedList ll = new LinkedList();
            ll.add(entry);

            // create the new entry in the hashmap
            _crcToEntryMap.put(crcL, ll);
          }
        }
      }
    }
Example #24
0
  /** Generates the transitive closure of the Class-Path attribute for the specified jar file. */
  List<String> getJarPath(String jar) throws IOException {
    List<String> files = new ArrayList<String>();
    files.add(jar);
    jarPaths.add(jar);

    // take out the current path
    String path = jar.substring(0, Math.max(0, jar.lastIndexOf('/') + 1));

    // class path attribute will give us jar file name with
    // '/' as separators, so we need to change them to the
    // appropriate one before we open the jar file.
    JarFile rf = new JarFile(jar.replace('/', File.separatorChar));

    if (rf != null) {
      Manifest man = rf.getManifest();
      if (man != null) {
        Attributes attr = man.getMainAttributes();
        if (attr != null) {
          String value = attr.getValue(Attributes.Name.CLASS_PATH);
          if (value != null) {
            StringTokenizer st = new StringTokenizer(value);
            while (st.hasMoreTokens()) {
              String ajar = st.nextToken();
              if (!ajar.endsWith("/")) { // it is a jar file
                ajar = path.concat(ajar);
                /* check on cyclic dependency */
                if (!jarPaths.contains(ajar)) {
                  files.addAll(getJarPath(ajar));
                }
              }
            }
          }
        }
      }
    }
    rf.close();
    return files;
  }
  protected boolean burnBootloader(Collection params) throws RunnerException {
    List fuses = new ArrayList();
    fuses.add("-e"); // erase the chip
    fuses.add(
        "-Ulock:w:"
            + Preferences.get("boards." + Preferences.get("board") + ".bootloader.unlock_bits")
            + ":m");
    if (Preferences.get("boards." + Preferences.get("board") + ".bootloader.extended_fuses")
        != null)
      fuses.add(
          "-Uefuse:w:"
              + Preferences.get("boards." + Preferences.get("board") + ".bootloader.extended_fuses")
              + ":m");
    fuses.add(
        "-Uhfuse:w:"
            + Preferences.get("boards." + Preferences.get("board") + ".bootloader.high_fuses")
            + ":m");
    fuses.add(
        "-Ulfuse:w:"
            + Preferences.get("boards." + Preferences.get("board") + ".bootloader.low_fuses")
            + ":m");

    if (!avrdude(params, fuses)) return false;

    List bootloader = new ArrayList();
    bootloader.add(
        "-Uflash:w:"
            + "hardware"
            + File.separator
            + "bootloaders"
            + File.separator
            + Preferences.get("boards." + Preferences.get("board") + ".bootloader.path")
            + File.separator
            + Preferences.get("boards." + Preferences.get("board") + ".bootloader.file")
            + ":i");
    bootloader.add(
        "-Ulock:w:"
            + Preferences.get("boards." + Preferences.get("board") + ".bootloader.lock_bits")
            + ":m");

    return avrdude(params, bootloader);
  }
Example #26
0
 public RowData[] select() {
   PreparedStatement stmt = null;
   try {
     stmt = conn.prepareStatement(selectStatement());
     ResultSet rs = stmt.executeQuery();
     List<RowData> list = new ArrayList<>();
     while (rs.next()) {
       String username = rs.getString("name");
       String b64string = rs.getString(b64DataName());
       list.add(new UserData(username, b64string));
     }
     return list.toArray(new RowData[0]);
   } catch (SQLException sqe) {
     sqe.printStackTrace();
     return null;
   } finally {
     if (stmt != null)
       try {
         stmt.close();
       } catch (SQLException sqe2) {
         sqe2.printStackTrace();
       }
   }
 }
Example #27
0
  // Declared in AnonymousClasses.jrag at line 52
  private AnonymousDecl rewriteRule0() {
    {
      setModifiers(new Modifiers(new List().add(new Modifier("final"))));

      ConstructorDecl constructor = new ConstructorDecl();
      addBodyDecl(constructor);

      constructor.setModifiers((Modifiers) constructorDecl().getModifiers().fullCopy());
      String name = "Anonymous" + nextAnonymousIndex();
      setID(name);
      constructor.setID(name);

      List parameterList = new List();
      for (int i = 0; i < constructorDecl().getNumParameter(); i++) {
        parameterList.add(
            new ParameterDeclaration(
                constructorDecl().getParameter(i).type().createBoundAccess(),
                constructorDecl().getParameter(i).name()));
      }
      constructor.setParameterList(parameterList);

      List argList = new List();
      for (int i = 0; i < constructor.getNumParameter(); i++)
        argList.add(new VarAccess(constructor.getParameter(i).name()));
      constructor.setConstructorInvocation(
          new ExprStmt(new SuperConstructorAccess("super", argList)));
      constructor.setBlock(new Block());

      HashSet set = new HashSet();
      for (int i = 0; i < getNumBodyDecl(); i++) {
        if (getBodyDecl(i) instanceof InstanceInitializer) {
          InstanceInitializer init = (InstanceInitializer) getBodyDecl(i);
          set.addAll(init.exceptions());
        } else if (getBodyDecl(i) instanceof FieldDeclaration) {
          FieldDeclaration f = (FieldDeclaration) getBodyDecl(i);
          if (f.isInstanceVariable()) {
            set.addAll(f.exceptions());
          }
        }
      }
      List exceptionList = new List();
      for (Iterator iter = set.iterator(); iter.hasNext(); ) {
        TypeDecl exceptionType = (TypeDecl) iter.next();
        if (exceptionType.isNull()) exceptionType = typeNullPointerException();
        exceptionList.add(exceptionType.createQualifiedAccess());
      }
      constructor.setExceptionList(exceptionList);
      return this;
    }
  }
  private Collection getProgrammerCommands(String programmer) {
    List params = new ArrayList();
    params.add("-c" + Preferences.get("programmers." + programmer + ".protocol"));

    if ("usb".equals(Preferences.get("programmers." + programmer + ".communication"))) {
      params.add("-Pusb");
    } else if ("serial".equals(Preferences.get("programmers." + programmer + ".communication"))) {
      params.add("-P" + (Base.isWindows() ? "\\\\.\\" : "") + Preferences.get("serial.port"));
      // XXX: add support for specifying the baud rate for serial programmers.
    }
    // XXX: add support for specifying the port address for parallel
    // programmers, although avrdude has a default that works in most cases.

    if (Preferences.get("programmers." + programmer + ".force") != null
        && Preferences.getBoolean("programmers." + programmer + ".force")) params.add("-F");

    if (Preferences.get("programmers." + programmer + ".delay") != null)
      params.add("-i" + Preferences.get("programmers." + programmer + ".delay"));

    return params;
  }
  private boolean uploadViaBootloader(String buildPath, String className) throws RunnerException {
    List commandDownloader = new ArrayList();
    String protocol = Preferences.get("boards." + Preferences.get("board") + ".upload.protocol");

    // avrdude wants "stk500v1" to distinguish it from stk500v2
    if (protocol.equals("stk500")) protocol = "stk500v1";
    commandDownloader.add("-c" + protocol);
    commandDownloader.add(
        "-P" + (Base.isWindows() ? "\\\\.\\" : "") + Preferences.get("serial.port"));
    commandDownloader.add(
        "-b" + Preferences.getInteger("boards." + Preferences.get("board") + ".upload.speed"));
    commandDownloader.add("-D"); // don't erase
    commandDownloader.add("-Uflash:w:" + buildPath + File.separator + className + ".hex:i");

    if (Preferences.get("boards." + Preferences.get("board") + ".upload.disable_flushing") == null
        || Preferences.getBoolean("boards." + Preferences.get("board") + ".upload.disable_flushing")
            == false) {
      flushSerialBuffer();
    }

    return avrdude(commandDownloader);
  }
Example #30
0
  static private List getCommandCompilerS(String avrBasePath, List includePaths,
    String sourceName, String objectName, Map<String, String> boardPreferences) {
    List baseCommandCompiler = new ArrayList(Arrays.asList(new String[] {
      avrBasePath + "avr-gcc",
      "-c", // compile, don't link
      "-g", // include debugging info (so errors include line numbers)
      "-assembler-with-cpp",
      "-mmcu=" + boardPreferences.get("build.mcu"),
      "-DF_CPU=" + boardPreferences.get("build.f_cpu"),      
      "-DARDUINO=" + Base.REVISION,
      "-DUSB_VID=" + boardPreferences.get("build.vid"),
      "-DUSB_PID=" + boardPreferences.get("build.pid"),
    }));

    for (int i = 0; i < includePaths.size(); i++) {
      baseCommandCompiler.add("-I" + (String) includePaths.get(i));
    }

    baseCommandCompiler.add(sourceName);
    baseCommandCompiler.add("-o"+ objectName);

    return baseCommandCompiler;
  }