use of io.sloeber.core.api.BoardDescriptor 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<>();
BoardDescriptor boardDescriptor = new InternalBoardDescriptor(confdesc);
// first add the referenced
IPath libPath = boardDescriptor.getReferencedLibraryPath();
if (libPath != null) {
ret.putAll(findAllSubFolders(libPath));
}
// then add the referencing
libPath = boardDescriptor.getReferencingLibraryPath();
if (libPath != null) {
ret.putAll(findAllSubFolders(libPath));
}
return ret;
}
use of io.sloeber.core.api.BoardDescriptor in project arduino-eclipse-plugin by Sloeber.
the class UploadSketchWrapper method internalUpload.
public void internalUpload(IProject project, String configName) {
ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(project);
ICConfigurationDescription confDesc = prjDesc.getConfigurationByName(configName);
BoardDescriptor boardDescriptor = BoardDescriptor.makeBoardDescriptor(confDesc);
String UpLoadTool = boardDescriptor.getActualUploadTool(confDesc);
String MComPort = boardDescriptor.getUploadPort();
String host = boardDescriptor.getHost();
String uploadClass = Common.getBuildEnvironmentVariable(confDesc, Common.get_ENV_KEY_TOOL(Const.UPLOAD_CLASS), new String());
this.myConsole = Helpers.findConsole(Messages.Upload_console);
this.myConsole.clearConsole();
this.myConsole.activate();
this.myHighLevelConsoleStream = this.myConsole.newMessageStream();
this.myOutconsoleStream = this.myConsole.newMessageStream();
this.myErrconsoleStream = this.myConsole.newMessageStream();
this.myHighLevelConsoleStream.setColor(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_BLACK));
this.myOutconsoleStream.setColor(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_DARK_GREEN));
this.myErrconsoleStream.setColor(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_RED));
this.myHighLevelConsoleStream.println(Messages.Upload_starting);
IRealUpload realUploader = null;
String uploadJobName = null;
if (host != null) {
if (Const.UPLOAD_CLASS_DEFAULT.equals(uploadClass)) {
this.myHighLevelConsoleStream.println(Messages.Upload_arduino);
realUploader = new arduinoUploader(project, configName, UpLoadTool, this.myConsole);
uploadJobName = UpLoadTool;
} else {
this.myHighLevelConsoleStream.println(Messages.Upload_ssh);
realUploader = new SSHUpload(project, UpLoadTool, this.myHighLevelConsoleStream, this.myOutconsoleStream, this.myErrconsoleStream, host);
uploadJobName = UPLOAD_SSH;
}
} else if (UpLoadTool.equalsIgnoreCase(UPLOAD_TOOL_TEENSY)) {
this.myHighLevelConsoleStream.println(Messages.Upload_generic);
realUploader = new GenericLocalUploader(UpLoadTool, project, configName, this.myConsole, this.myErrconsoleStream, this.myOutconsoleStream);
uploadJobName = UpLoadTool;
} else {
this.myHighLevelConsoleStream.println(Messages.Upload_arduino);
realUploader = new arduinoUploader(project, configName, UpLoadTool, this.myConsole);
uploadJobName = UpLoadTool;
}
Job uploadjob = new UploadJobWrapper(uploadJobName, project, configName, realUploader, MComPort, boardDescriptor);
uploadjob.setRule(null);
uploadjob.setPriority(Job.LONG);
uploadjob.setUser(true);
uploadjob.schedule();
Job job = new Job(Messages.Upload_PluginStartInitiator) {
@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();
}
use of io.sloeber.core.api.BoardDescriptor in project arduino-eclipse-plugin by Sloeber.
the class arduinoUploader method uploadUsingPreferences.
@Override
public boolean uploadUsingPreferences(IFile hexFile, BoardDescriptor inBoardDescriptor, IProgressMonitor monitor) {
String MComPort = new String();
String boardName = new String();
boolean needsPassword = false;
boolean needsUpdatedConfig = false;
BoardDescriptor boardDescriptor = BoardDescriptor.makeBoardDescriptor(inBoardDescriptor);
IEnvironmentVariableManager envManager = CCorePlugin.getDefault().getBuildEnvironmentManager();
IContributedEnvironment contribEnv = envManager.getContributedEnvironment();
ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(this.myProject);
ICConfigurationDescription configurationDescription = prjDesc.getConfigurationByName(this.mycConf);
try {
needsPassword = envManager.getVariable(Const.ENV_KEY_NETWORK_AUTH, configurationDescription, true).getValue().equalsIgnoreCase(Const.TRUE);
} catch (Exception e) {
// ignore all errors
}
if (!boardDescriptor.usesProgrammer()) {
String NewSerialPort = ArduinoSerial.makeArduinoUploadready(this.myConsole.newMessageStream(), this.myProject, this.mycConf, boardDescriptor);
if (!boardDescriptor.getUploadPort().equals(NewSerialPort)) {
boardDescriptor.setUploadPort(NewSerialPort);
needsUpdatedConfig = true;
}
}
// for web authorized upload
if (needsPassword) {
setEnvironmentvarsForAutorizedUpload(contribEnv, configurationDescription, MComPort);
}
if (needsUpdatedConfig) {
try {
boardDescriptor.saveConfiguration(configurationDescription, null);
} catch (Exception e) {
Common.log(new // $NON-NLS-1$
Status(// $NON-NLS-1$
IStatus.ERROR, // $NON-NLS-1$
Const.CORE_PLUGIN_ID, // $NON-NLS-1$
"Failed to save configuration before upload", e));
return false;
}
}
String command = boardDescriptor.getUploadCommand(configurationDescription);
if (command == null) {
// $NON-NLS-1$
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, "Failed to get the Upload recipe "));
return false;
}
try {
GenericLocalUploader.RunConsoledCommand(this.myConsole, command, monitor);
} catch (IOException e1) {
// $NON-NLS-1$
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, "Failed to run the Upload recipe ", e1));
return false;
}
if (boardName.startsWith("Arduino Due ")) {
// $NON-NLS-1$
ArduinoSerial.reset_Arduino_by_baud_rate(MComPort, 115200, 100);
}
return true;
}
use of io.sloeber.core.api.BoardDescriptor in project arduino-eclipse-plugin by Sloeber.
the class NewSketchWizard method createProjectWrapper.
protected void createProjectWrapper(IProgressMonitor monitor) {
BoardDescriptor boardID = this.mArduinoPage.getBoardID();
CodeDescriptor codeDescription = this.mNewArduinoSketchWizardCodeSelectionPage.getCodeDescription();
try {
this.mProject = boardID.createProject(this.mWizardPage.getProjectName(), (!this.mWizardPage.useDefaults()) ? this.mWizardPage.getLocationURI() : null, ConfigurationDescriptor.getDefaultDescriptors(), codeDescription, new CompileOptions(null), monitor);
} catch (Exception e) {
this.mProject = null;
Activator.log(new Status(IStatus.ERROR, Activator.getId(), Messages.ui_new_sketch_error_failed_to_create_project, e));
}
}
use of io.sloeber.core.api.BoardDescriptor in project arduino-eclipse-plugin by Sloeber.
the class CreateAndCompileArduinoIDEExamplesOnTeensyTest method testExample.
public void testExample(MCUBoard board) {
// failures
if (totalFails >= maxFails) {
fail("To many fails. Stopping test");
}
if (!board.isExampleSupported(myExample)) {
return;
}
Map<String, String> boardOptions = board.getBoardOptions(myExample);
BoardDescriptor boardDescriptor = board.getBoardDescriptor();
boardDescriptor.setOptions(boardOptions);
BuildAndVerify(boardDescriptor);
}
Aggregations