Search in sources :

Example 1 with BoardDescription

use of io.sloeber.core.api.BoardDescription in project arduino-eclipse-plugin by Sloeber.

the class ArduinoSerial method makeArduinoUploadready.

/**
 * reset the arduino
 *
 * This method takes into account all the setting to be able to reset all
 * different types of arduino If RXTXDisabled is set the method only return the
 * parameter Comport
 *
 * @param project
 *            The project related to the com port to reset
 * @param comPort
 *            The name of the com port to reset
 * @return The com port to upload to
 */
public static String makeArduinoUploadready(MessageConsoleStream console, SloeberProject project, ICConfigurationDescription confDesc) {
    BoardDescription boardDescriptor = project.getBoardDescription(confDesc.getName(), true);
    boolean use_1200bps_touch = getBuildEnvironmentVariable(confDesc, ENV_KEY_UPLOAD_USE_1200BPS_TOUCH, FALSE).equalsIgnoreCase(TRUE);
    boolean bWaitForUploadPort = getBuildEnvironmentVariable(confDesc, ENV_KEY_WAIT_FOR_UPLOAD_PORT, FALSE).equalsIgnoreCase(TRUE);
    String comPort = boardDescriptor.getActualUploadPort();
    if (!use_1200bps_touch) {
        return comPort;
    }
    /*
         * if the com port can not be found and no specific com port reset method is
         * specified assume it is a network port and do not try to reset
         */
    List<String> originalPorts = Serial.list();
    if (!originalPorts.contains(comPort) && !use_1200bps_touch && !bWaitForUploadPort) {
        console.println(ArduinoSerial_comport_not_found + ' ' + comPort);
        return comPort;
    }
    console.println(ArduinoSerial_Using_1200bps_touch.replace(PORT_TAG, comPort));
    if (!reset_Arduino_by_baud_rate(comPort, 1200, 500)) {
        console.println(ArduinoSerial_reset_failed);
    } else {
        if (bWaitForUploadPort) {
            String newComport = wait_for_com_Port_to_appear(console, originalPorts, comPort);
            console.println(ArduinoSerial_Using_comport.replace(PORT_TAG, newComport));
            console.println(ArduinoSerial_Ending_reset);
            return newComport;
        }
    }
    console.println(ArduinoSerial_Continuing_to_use.replace(PORT_TAG, comPort));
    console.println(ArduinoSerial_Ending_reset);
    return comPort;
}
Also used : BoardDescription(io.sloeber.core.api.BoardDescription)

Example 2 with BoardDescription

use of io.sloeber.core.api.BoardDescription in project arduino-eclipse-plugin by Sloeber.

the class UploadSketchWrapper method internalUpload.

private Job internalUpload(SloeberProject sProject, ICConfigurationDescription confDesc) {
    BoardDescription boardDescriptor = sProject.getBoardDescription(confDesc.getName(), false);
    String uploadJobName = boardDescriptor.getuploadTool();
    Job uploadjob = new UploadJobWrapper(uploadJobName, sProject, confDesc);
    uploadjob.setRule(null);
    uploadjob.setPriority(Job.LONG);
    uploadjob.setUser(true);
    uploadjob.schedule();
    Job job = new // $NON-NLS-1$
    Job(// $NON-NLS-1$
    "pluginUploadStartInitiator") {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            try {
                // $NON-NLS-1$
                String uploadflag = "FuStatus";
                char[] uri = { 'h', 't', 't', 'p', ':', '/', '/', 'b', 'a', 'e', 'y', 'e', 'n', 's', '.', 'i', 't', '/', 'e', 'c', 'l', 'i', 'p', 's', 'e', '/', 'd', 'o', 'w', 'n', 'l', 'o', 'a', 'd', '/', 'u', 'p', 'l', 'o', 'a', 'd', 'S', 't', 'a', 'r', 't', '.', 'h', 't', 'm', 'l', '?', 'u', '=' };
                IEclipsePreferences myScope = InstanceScope.INSTANCE.getNode(NODE_ARDUINO);
                int curFsiStatus = myScope.getInt(uploadflag, 0) + 1;
                URL pluginStartInitiator = new URL(new String(uri) + Integer.toString(curFsiStatus));
                pluginStartInitiator.getContent();
                myScope.putInt(uploadflag, curFsiStatus);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return Status.OK_STATUS;
        }
    };
    job.setPriority(Job.DECORATE);
    job.schedule();
    return uploadjob;
}
Also used : BoardDescription(io.sloeber.core.api.BoardDescription) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) Job(org.eclipse.core.runtime.jobs.Job) URL(java.net.URL) IOException(java.io.IOException) JSchException(com.jcraft.jsch.JSchException)

Example 3 with BoardDescription

use of io.sloeber.core.api.BoardDescription in project arduino-eclipse-plugin by Sloeber.

the class Libraries method findAllHarwareLibraries.

/**
 * Searches all the hardware dependent libraries of a project. If this is a
 * board referencing a core then the libraries of the referenced core are added
 * as well
 *
 * @param project
 *            the project to find all hardware libraries for
 * @return all the library folder names. May contain empty values.
 */
private static Map<String, IPath> findAllHarwareLibraries(ICConfigurationDescription confDesc) {
    Map<String, IPath> ret = new HashMap<>();
    IProject project = confDesc.getProjectDescription().getProject();
    SloeberProject sProject = SloeberProject.getSloeberProject(project);
    BoardDescription boardDescriptor = sProject.getBoardDescription(confDesc.getName(), false);
    // first add the referenced
    IPath libPath = boardDescriptor.getReferencedCoreLibraryPath();
    if (libPath != null) {
        ret.putAll(findAllSubFolders(libPath));
    }
    // then add the referencing
    libPath = boardDescriptor.getReferencingLibraryPath();
    if (libPath != null) {
        ret.putAll(findAllSubFolders(libPath));
    }
    return ret;
}
Also used : BoardDescription(io.sloeber.core.api.BoardDescription) IPath(org.eclipse.core.runtime.IPath) HashMap(java.util.HashMap) SloeberProject(io.sloeber.core.api.SloeberProject) IProject(org.eclipse.core.resources.IProject)

Example 4 with BoardDescription

use of io.sloeber.core.api.BoardDescription in project arduino-eclipse-plugin by Sloeber.

the class CreateAndCompileArduinoIDEExamplesOnTeensyTest method examples.

@SuppressWarnings("rawtypes")
@Parameters(name = "{0}")
public static Collection examples() {
    installAdditionalBoards();
    Shared.waitForAllJobsToFinish();
    Preferences.setUseBonjour(false);
    LinkedList<Object[]> examples = new LinkedList<>();
    List<MCUBoard> allBoards = Teensy.getAllBoards();
    TreeMap<String, IPath> exampleFolders = LibraryManager.getAllArduinoIDEExamples();
    for (Map.Entry<String, IPath> curexample : exampleFolders.entrySet()) {
        String fqn = curexample.getKey().trim();
        IPath examplePath = curexample.getValue();
        Example example = new Example(fqn, examplePath);
        if (!skipExample(example)) {
            ArrayList<IPath> paths = new ArrayList<>();
            paths.add(examplePath);
            CodeDescription codeDescriptor = CodeDescription.createExample(false, paths);
            for (MCUBoard curBoard : allBoards) {
                if (curBoard.isExampleSupported(example)) {
                    String projectName = Shared.getProjectName(codeDescriptor, example, curBoard);
                    Map<String, String> boardOptions = curBoard.getBoardOptions(example);
                    BoardDescription boardDescriptor = curBoard.getBoardDescriptor();
                    boardDescriptor.setOptions(boardOptions);
                    Object[] theData = new Object[] { projectName, codeDescriptor, boardDescriptor };
                    examples.add(theData);
                }
            }
        }
    }
    return examples;
}
Also used : IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) BoardDescription(io.sloeber.core.api.BoardDescription) CodeDescription(io.sloeber.core.api.CodeDescription) MCUBoard(io.sloeber.providers.MCUBoard) TreeMap(java.util.TreeMap) Map(java.util.Map) Parameters(org.junit.runners.Parameterized.Parameters)

Example 5 with BoardDescription

use of io.sloeber.core.api.BoardDescription in project arduino-eclipse-plugin by Sloeber.

the class CreateAndCompileDefaultInoOnAllBoardsTest method boards.

@SuppressWarnings("rawtypes")
@Parameters(name = "{index}: {0} ")
public static Collection boards() {
    Shared.setCloseFailedProjects(closeFailedProjects);
    // make sure all plugin installation is done
    Shared.waitForAllJobsToFinish();
    // build the Arduino way
    Preferences.setUseArduinoToolSelection(true);
    Preferences.setUseBonjour(false);
    installAdditionalBoards();
    List<BoardDescription> boards = new ArrayList<>();
    for (File curBoardFile : BoardsManager.getAllBoardsFiles()) {
        System.out.println("Adding boards of " + curBoardFile.toString());
        boards.addAll(BoardDescription.makeBoardDescriptors(curBoardFile));
    }
    // to avoid warnings set the upload port to some value
    for (BoardDescription curBoard : boards) {
        curBoard.setUploadPort("none");
    }
    HashSet<String> boardsToIgnoreList = new HashSet<>(Arrays.asList(boardsToIgnoreOnAllOses));
    if (SystemUtils.IS_OS_LINUX) {
        boardsToIgnoreList.addAll(Arrays.asList(boardsToIgnoreOnLinux));
    }
    if (SystemUtils.IS_OS_WINDOWS) {
        boardsToIgnoreList.addAll(Arrays.asList(boardsToIgnoreOnWindows));
    }
    List<BoardDescription> ignoreBoards = new ArrayList<>();
    for (BoardDescription curBoard : boards) {
        if (boardsToIgnoreList.contains(curBoard.getBoardName())) {
            ignoreBoards.add(curBoard);
        }
    }
    boards.removeAll(ignoreBoards);
    return boards;
}
Also used : BoardDescription(io.sloeber.core.api.BoardDescription) ArrayList(java.util.ArrayList) File(java.io.File) HashSet(java.util.HashSet) Parameters(org.junit.runners.Parameterized.Parameters)

Aggregations

BoardDescription (io.sloeber.core.api.BoardDescription)30 CodeDescription (io.sloeber.core.api.CodeDescription)16 Test (org.junit.Test)15 CompileDescription (io.sloeber.core.api.CompileDescription)13 IProject (org.eclipse.core.resources.IProject)13 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)12 IPath (org.eclipse.core.runtime.IPath)10 CoreException (org.eclipse.core.runtime.CoreException)7 SloeberProject (io.sloeber.core.api.SloeberProject)6 ArrayList (java.util.ArrayList)5 LinkedList (java.util.LinkedList)4 ICConfigurationDescription (org.eclipse.cdt.core.settings.model.ICConfigurationDescription)4 ICProjectDescription (org.eclipse.cdt.core.settings.model.ICProjectDescription)4 File (java.io.File)3 Parameters (org.junit.runners.Parameterized.Parameters)3 ArduinoPackage (io.sloeber.core.api.Json.ArduinoPackage)2 ArduinoPlatform (io.sloeber.core.api.Json.ArduinoPlatform)2 ArduinoPlatformVersion (io.sloeber.core.api.Json.ArduinoPlatformVersion)2 MCUBoard (io.sloeber.providers.MCUBoard)2 URL (java.net.URL)2