mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-29 18:52:13 +01:00
Added warning for uncertified boards
This commit is contained in:
parent
25ddcb852f
commit
39d1dfc999
57
app/src/cc/arduino/view/Event.java
Normal file
57
app/src/cc/arduino/view/Event.java
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* This file is part of Arduino.
|
||||
*
|
||||
* Arduino is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2015 Arduino LLC (http://www.arduino.cc/)
|
||||
*/
|
||||
|
||||
package cc.arduino.view;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Event extends ActionEvent {
|
||||
|
||||
private final Map<String, Object> payload;
|
||||
|
||||
public Event(Object source, int id, String command) {
|
||||
super(source, id, command);
|
||||
this.payload = new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
public Map<String, Object> getPayload() {
|
||||
return payload;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(super.toString());
|
||||
sb.append("\n").append(payload.toString());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
36
app/src/cc/arduino/view/EventListener.java
Normal file
36
app/src/cc/arduino/view/EventListener.java
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* This file is part of Arduino.
|
||||
*
|
||||
* Arduino is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2015 Arduino LLC (http://www.arduino.cc/)
|
||||
*/
|
||||
|
||||
package cc.arduino.view;
|
||||
|
||||
public interface EventListener {
|
||||
|
||||
void eventHappened(Event event);
|
||||
|
||||
}
|
59
app/src/cc/arduino/view/ShowUncertifiedBoardWarning.java
Normal file
59
app/src/cc/arduino/view/ShowUncertifiedBoardWarning.java
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of Arduino.
|
||||
*
|
||||
* Arduino is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2015 Arduino LLC (http://www.arduino.cc/)
|
||||
*/
|
||||
|
||||
package cc.arduino.view;
|
||||
|
||||
import processing.app.Preferences;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class ShowUncertifiedBoardWarning implements Runnable {
|
||||
|
||||
private final Frame parent;
|
||||
|
||||
public ShowUncertifiedBoardWarning(Frame parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
UncertifiedBoardWarning uncertifiedBoardWarning = new UncertifiedBoardWarning(parent, new EventListener() {
|
||||
@Override
|
||||
public void eventHappened(cc.arduino.view.Event event) {
|
||||
if (!"uncertified_board_warning_ok_pressed".equals(event.getActionCommand())) {
|
||||
return;
|
||||
}
|
||||
Preferences.set("uncertifiedBoardWarning_dontShowMeAgain", event.getPayload().get("dontShowMeAgain").toString());
|
||||
}
|
||||
});
|
||||
uncertifiedBoardWarning.setLocationRelativeTo(parent);
|
||||
uncertifiedBoardWarning.setVisible(true);
|
||||
}
|
||||
|
||||
}
|
81
app/src/cc/arduino/view/UncertifiedBoardWarning.form
Normal file
81
app/src/cc/arduino/view/UncertifiedBoardWarning.form
Normal file
@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
<Property name="title" type="java.lang.String" value="_("Not supported board")"/>
|
||||
<Property name="modal" type="boolean" value="true"/>
|
||||
<Property name="name" type="java.lang.String" value="uncertifiedBoardWarning" noResource="true"/>
|
||||
<Property name="resizable" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel1" pref="0" max="32767" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="dontShowMeAgain" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="206" max="32767" attributes="0"/>
|
||||
<Component id="ok" min="-2" pref="82" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" min="-2" pref="87" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="dontShowMeAgain" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="ok" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="<html><body>This board comes from an non certified manufacturer.<br>We won't be able to provide any support if it doesn't work as expected.</body></html>"/>
|
||||
<Property name="verticalAlignment" type="int" value="1"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="dontShowMeAgain">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Don't show me again"/>
|
||||
<Property name="name" type="java.lang.String" value="dontShowMeAgain" noResource="true"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="ok">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="OK"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
146
app/src/cc/arduino/view/UncertifiedBoardWarning.java
Normal file
146
app/src/cc/arduino/view/UncertifiedBoardWarning.java
Normal file
@ -0,0 +1,146 @@
|
||||
/*
|
||||
* This file is part of Arduino.
|
||||
*
|
||||
* Arduino is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2015 Arduino LLC (http://www.arduino.cc/)
|
||||
*/
|
||||
|
||||
package cc.arduino.view;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
|
||||
public class UncertifiedBoardWarning extends javax.swing.JDialog {
|
||||
|
||||
private final EventListener listener;
|
||||
|
||||
public UncertifiedBoardWarning(Frame parent, EventListener listener) {
|
||||
super(parent);
|
||||
initComponents();
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
dontShowMeAgain = new javax.swing.JCheckBox();
|
||||
ok = new javax.swing.JButton();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setTitle(_("Uncertified board"));
|
||||
setModal(true);
|
||||
setName("uncertifiedBoardWarning"); // NOI18N
|
||||
setResizable(false);
|
||||
|
||||
jLabel1.setText("<html><body>" + _("This board comes from an uncertified manufacturer.") + "<br>" + _("We won't be able to provide any support if it doesn't work as expected.") + "</body></html>");
|
||||
jLabel1.setVerticalAlignment(javax.swing.SwingConstants.TOP);
|
||||
|
||||
dontShowMeAgain.setText("Don't show me again");
|
||||
dontShowMeAgain.setName("dontShowMeAgain"); // NOI18N
|
||||
|
||||
ok.setText("OK");
|
||||
ok.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
okActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(dontShowMeAgain)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 206, Short.MAX_VALUE)
|
||||
.addComponent(ok, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(dontShowMeAgain)
|
||||
.addComponent(ok))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void okActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okActionPerformed
|
||||
Event event = new Event(evt.getSource(), evt.getID(), "uncertified_board_warning_ok_pressed");
|
||||
event.getPayload().put("dontShowMeAgain", dontShowMeAgain.isSelected());
|
||||
listener.eventHappened(event);
|
||||
this.dispose();
|
||||
}//GEN-LAST:event_okActionPerformed
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) throws Exception {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
/* Create and display the dialog */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
UncertifiedBoardWarning dialog = new UncertifiedBoardWarning(new javax.swing.JFrame(), new EventListener() {
|
||||
|
||||
@Override
|
||||
public void eventHappened(Event event) {
|
||||
System.out.println(event);
|
||||
}
|
||||
});
|
||||
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(java.awt.event.WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JCheckBox dontShowMeAgain;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JButton ok;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
@ -24,6 +24,9 @@ package processing.app;
|
||||
|
||||
import cc.arduino.packages.MonitorFactory;
|
||||
|
||||
import cc.arduino.view.*;
|
||||
import cc.arduino.view.Event;
|
||||
import cc.arduino.view.EventListener;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
|
||||
import jssc.SerialPortException;
|
||||
@ -944,15 +947,22 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
class SerialMenuListener implements ActionListener {
|
||||
|
||||
private final Frame parent;
|
||||
private final String serialPort;
|
||||
private final String warning;
|
||||
|
||||
public SerialMenuListener(String serialPort) {
|
||||
public SerialMenuListener(Frame parent, String serialPort, String warning) {
|
||||
this.parent = parent;
|
||||
this.serialPort = serialPort;
|
||||
this.warning = warning;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
selectSerialPort(serialPort);
|
||||
base.onBoardOrPortChange();
|
||||
if (warning != null && !Preferences.getBoolean("uncertifiedBoardWarning_dontShowMeAgain")) {
|
||||
SwingUtilities.invokeLater(new ShowUncertifiedBoardWarning(parent));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1034,7 +1044,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
String label = port.getLabel();
|
||||
|
||||
JCheckBoxMenuItem item = new JCheckBoxMenuItem(label, address.equals(selectedPort));
|
||||
item.addActionListener(new SerialMenuListener(address));
|
||||
item.addActionListener(new SerialMenuListener(this, address, port.getPrefs().get("warning")));
|
||||
serialMenu.add(item);
|
||||
}
|
||||
|
||||
|
@ -23,12 +23,16 @@
|
||||
|
||||
package processing.app;
|
||||
|
||||
import cc.arduino.packages.BoardPort;
|
||||
import cc.arduino.packages.Uploader;
|
||||
import cc.arduino.view.*;
|
||||
import processing.app.debug.Compiler;
|
||||
import processing.app.debug.Compiler.ProgressListener;
|
||||
import processing.app.debug.RunnerException;
|
||||
import processing.app.debug.TargetBoard;
|
||||
import processing.app.forms.PasswordAuthorizationDialog;
|
||||
import processing.app.helpers.OSUtils;
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
import processing.app.helpers.PreferencesMapException;
|
||||
import processing.app.packages.Library;
|
||||
|
||||
@ -1148,6 +1152,8 @@ public class Sketch {
|
||||
* @return null if compilation failed, main class name if not
|
||||
*/
|
||||
public String build(String buildPath, boolean verbose) throws RunnerException, PreferencesMapException {
|
||||
useOriginalVidPidIfUncertified();
|
||||
|
||||
// run the preprocessor
|
||||
editor.status.progressUpdate(20);
|
||||
|
||||
@ -1197,6 +1203,37 @@ public class Sketch {
|
||||
return success;
|
||||
}
|
||||
|
||||
private void useOriginalVidPidIfUncertified() {
|
||||
BoardPort boardPort = BaseNoGui.getDiscoveryManager().find(PreferencesData.get("serial.port"));
|
||||
if (boardPort == null) {
|
||||
return;
|
||||
}
|
||||
TargetBoard targetBoard = BaseNoGui.getTargetBoard();
|
||||
if (targetBoard == null) {
|
||||
return;
|
||||
}
|
||||
PreferencesMap boardPreferences = targetBoard.getPreferences();
|
||||
if (boardPreferences.containsKey("build.vid") && boardPreferences.containsKey("build.pid")) {
|
||||
if (!boardPreferences.containsKey("backup.build.vid")) {
|
||||
boardPreferences.put("backup.build.vid", boardPreferences.get("build.vid"));
|
||||
boardPreferences.put("backup.build.pid", boardPreferences.get("build.pid"));
|
||||
}
|
||||
|
||||
if (boardPort.getPrefs().get("warning") != null) {
|
||||
boardPreferences.put("build.vid", boardPort.getPrefs().get("vid"));
|
||||
boardPreferences.put("build.pid", boardPort.getPrefs().get("pid"));
|
||||
} else {
|
||||
boardPreferences.put("build.vid", boardPreferences.get("backup.build.vid"));
|
||||
boardPreferences.put("build.pid", boardPreferences.get("backup.build.pid"));
|
||||
}
|
||||
}
|
||||
|
||||
if (boardPort.getPrefs().get("warning") != null && !Preferences.getBoolean("uncertifiedBoardWarning_dontShowMeAgain")) {
|
||||
SwingUtilities.invokeLater(new ShowUncertifiedBoardWarning(editor));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected boolean upload(String buildPath, String suggestedClassName, boolean usingProgrammer) throws Exception {
|
||||
|
||||
|
@ -29,18 +29,27 @@
|
||||
|
||||
package cc.arduino.packages.discoverers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cc.arduino.packages.BoardPort;
|
||||
import cc.arduino.packages.Discovery;
|
||||
import processing.app.BaseNoGui;
|
||||
import processing.app.Platform;
|
||||
import processing.app.Serial;
|
||||
import processing.app.debug.TargetBoard;
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
import cc.arduino.packages.BoardPort;
|
||||
import cc.arduino.packages.Discovery;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
|
||||
public class SerialDiscovery implements Discovery {
|
||||
|
||||
static {
|
||||
//makes transifex happy
|
||||
_("Uncertified");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BoardPort> discovery() {
|
||||
Platform os = BaseNoGui.getPlatform();
|
||||
@ -51,16 +60,35 @@ public class SerialDiscovery implements Discovery {
|
||||
List<String> ports = Serial.list();
|
||||
|
||||
for (String port : ports) {
|
||||
String boardName = os.resolveDeviceAttachedTo(port, BaseNoGui.packages, devicesListOutput);
|
||||
String label = port;
|
||||
if (boardName != null)
|
||||
label += " (" + boardName + ")";
|
||||
Map<String, Object> boardData = os.resolveDeviceAttachedTo(port, BaseNoGui.packages, devicesListOutput);
|
||||
TargetBoard board = (TargetBoard) boardData.get("board");
|
||||
|
||||
BoardPort boardPort = new BoardPort();
|
||||
boardPort.setAddress(port);
|
||||
boardPort.setProtocol("serial");
|
||||
|
||||
PreferencesMap prefs = new PreferencesMap();
|
||||
prefs.put("vid", boardData.get("vid").toString());
|
||||
prefs.put("pid", boardData.get("pid").toString());
|
||||
String warningKey = "vid." + boardData.get("vid").toString() + ".warning";
|
||||
String warning = board.getPreferences().get(warningKey);
|
||||
prefs.put("warning", warning);
|
||||
|
||||
String boardName = board.getName();
|
||||
String label = port;
|
||||
if (boardName != null) {
|
||||
if (warning != null) {
|
||||
label += " (" + boardName + " - " + _(warning) + ")";
|
||||
} else {
|
||||
label += " (" + boardName + ")";
|
||||
}
|
||||
}
|
||||
boardPort.setBoardName(boardName);
|
||||
boardPort.setLabel(label);
|
||||
|
||||
|
||||
boardPort.setPrefs(prefs);
|
||||
|
||||
res.add(boardPort);
|
||||
}
|
||||
return res;
|
||||
|
@ -24,6 +24,7 @@ package processing.app;
|
||||
import static processing.app.I18n._;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -135,7 +136,7 @@ public class Platform {
|
||||
}
|
||||
}
|
||||
|
||||
public String resolveDeviceAttachedTo(String serial, Map<String, TargetPackage> packages, String devicesListOutput) {
|
||||
public Map<String, Object> resolveDeviceAttachedTo(String serial, Map<String, TargetPackage> packages, String devicesListOutput) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -143,17 +144,21 @@ public class Platform {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String resolveDeviceByVendorIdProductId(Map<String, TargetPackage> packages, String readVIDPID) {
|
||||
protected Map<String, Object> resolveDeviceByVendorIdProductId(Map<String, TargetPackage> packages, String readVIDPID) {
|
||||
for (TargetPackage targetPackage : packages.values()) {
|
||||
for (TargetPlatform targetPlatform : targetPackage.getPlatforms().values()) {
|
||||
for (TargetBoard board : targetPlatform.getBoards().values()) {
|
||||
List<String> vids = new LinkedList<String>(board.getPreferences().subTree("vid").values());
|
||||
List<String> vids = new LinkedList<String>(board.getPreferences().subTree("vid", 1).values());
|
||||
if (!vids.isEmpty()) {
|
||||
List<String> pids = new LinkedList<String>(board.getPreferences().subTree("pid").values());
|
||||
for (int i = 0; i< vids.size(); i++) {
|
||||
List<String> pids = new LinkedList<String>(board.getPreferences().subTree("pid", 1).values());
|
||||
for (int i = 0; i < vids.size(); i++) {
|
||||
String vidPid = vids.get(i) + "_" + pids.get(i);
|
||||
if (vidPid.toUpperCase().equals(readVIDPID)) {
|
||||
return board.getName();
|
||||
Map<String, Object> boardData = new HashMap<String, Object>();
|
||||
boardData.put("board", board);
|
||||
boardData.put("vid", vids.get(i));
|
||||
boardData.put("pid", pids.get(i));
|
||||
return boardData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -222,12 +222,21 @@ public class PreferencesMap extends LinkedHashMap<String, String> {
|
||||
* @return
|
||||
*/
|
||||
public PreferencesMap subTree(String parent) {
|
||||
return subTree(parent, -1);
|
||||
}
|
||||
|
||||
public PreferencesMap subTree(String parent, int sublevels) {
|
||||
PreferencesMap res = new PreferencesMap();
|
||||
parent += ".";
|
||||
int parentLen = parent.length();
|
||||
for (String key : keySet()) {
|
||||
if (key.startsWith(parent))
|
||||
res.put(key.substring(parentLen), get(key));
|
||||
if (key.startsWith(parent)) {
|
||||
String newKey = key.substring(parentLen);
|
||||
int keySubLevels = newKey.split("\\.").length;
|
||||
if (sublevels == -1 || keySubLevels == sublevels) {
|
||||
res.put(newKey, get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ public class Platform extends processing.app.Platform {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String resolveDeviceAttachedTo(String serial, Map<String, TargetPackage> packages, String devicesListOutput) {
|
||||
public Map<String, Object> resolveDeviceAttachedTo(String serial, Map<String, TargetPackage> packages, String devicesListOutput) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
Executor executor = new ExternalProcessExecutor(baos);
|
||||
|
||||
|
@ -210,7 +210,7 @@ public class Platform extends processing.app.Platform {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String resolveDeviceAttachedTo(String serial, Map<String, TargetPackage> packages, String devicesListOutput) {
|
||||
public Map<String, Object> resolveDeviceAttachedTo(String serial, Map<String, TargetPackage> packages, String devicesListOutput) {
|
||||
if (devicesListOutput == null) {
|
||||
return super.resolveDeviceAttachedTo(serial, packages, devicesListOutput);
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ public class Platform extends processing.app.Platform {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String resolveDeviceAttachedTo(String serial, Map<String, TargetPackage> packages, String devicesListOutput) {
|
||||
public Map<String, Object> resolveDeviceAttachedTo(String serial, Map<String, TargetPackage> packages, String devicesListOutput) {
|
||||
if (devicesListOutput == null) {
|
||||
return super.resolveDeviceAttachedTo(serial, packages, devicesListOutput);
|
||||
}
|
||||
|
@ -11,6 +11,13 @@ yun.vid.0=0x2341
|
||||
yun.pid.0=0x0041
|
||||
yun.vid.1=0x2341
|
||||
yun.pid.1=0x8041
|
||||
yun.vid.2=0x2A03
|
||||
yun.pid.2=0x0041
|
||||
yun.vid.3=0x2A03
|
||||
yun.pid.3=0x8041
|
||||
|
||||
yun.vid.0x2A03.warning=Uncertified
|
||||
|
||||
yun.upload.tool=avrdude
|
||||
yun.upload.protocol=avr109
|
||||
yun.upload.maximum_size=28672
|
||||
@ -46,6 +53,10 @@ uno.vid.0=0x2341
|
||||
uno.pid.0=0x0043
|
||||
uno.vid.1=0x2341
|
||||
uno.pid.1=0x0001
|
||||
uno.vid.2=0x2A03
|
||||
uno.pid.2=0x0043
|
||||
|
||||
uno.vid.0x2A03.warning=Uncertified
|
||||
|
||||
uno.upload.tool=avrdude
|
||||
uno.upload.protocol=arduino
|
||||
@ -166,6 +177,12 @@ mega.vid.0=0x2341
|
||||
mega.pid.0=0x0010
|
||||
mega.vid.1=0x2341
|
||||
mega.pid.1=0x0042
|
||||
mega.vid.2=0x2A03
|
||||
mega.pid.2=0x0010
|
||||
mega.vid.3=0x2A03
|
||||
mega.pid.3=0x0042
|
||||
|
||||
mega.vid.0x2A03.warning=Uncertified
|
||||
|
||||
mega.upload.tool=avrdude
|
||||
mega.upload.maximum_data_size=8192
|
||||
@ -219,6 +236,12 @@ megaADK.vid.0=0x2341
|
||||
megaADK.pid.0=0x003f
|
||||
megaADK.vid.1=0x2341
|
||||
megaADK.pid.1=0x0044
|
||||
megaADK.vid.2=0x2A03
|
||||
megaADK.pid.2=0x003f
|
||||
megaADK.vid.3=0x2A03
|
||||
megaADK.pid.3=0x0044
|
||||
|
||||
megaADK.vid.0x2A03.warning=Uncertified
|
||||
|
||||
megaADK.upload.tool=avrdude
|
||||
megaADK.upload.protocol=wiring
|
||||
@ -247,6 +270,13 @@ leonardo.vid.0=0x2341
|
||||
leonardo.pid.0=0x0036
|
||||
leonardo.vid.1=0x2341
|
||||
leonardo.pid.1=0x8036
|
||||
leonardo.vid.2=0x2A03
|
||||
leonardo.pid.2=0x0036
|
||||
leonardo.vid.3=0x2A03
|
||||
leonardo.pid.3=0x8036
|
||||
|
||||
leonardo.vid.0x2A03.warning=Uncertified
|
||||
|
||||
leonardo.upload.tool=avrdude
|
||||
leonardo.upload.protocol=avr109
|
||||
leonardo.upload.maximum_size=28672
|
||||
@ -277,6 +307,17 @@ leonardo.build.extra_flags={build.usb_flags}
|
||||
##############################################################
|
||||
|
||||
micro.name=Arduino Micro
|
||||
micro.vid.0=0x2341
|
||||
micro.pid.0=0x0037
|
||||
micro.vid.1=0x2341
|
||||
micro.pid.1=0x8037
|
||||
micro.vid.2=0x2A03
|
||||
micro.pid.2=0x0037
|
||||
micro.vid.3=0x2A03
|
||||
micro.pid.3=0x8037
|
||||
|
||||
micro.vid.0x2A03.warning=Uncertified
|
||||
|
||||
micro.upload.tool=avrdude
|
||||
micro.upload.protocol=avr109
|
||||
micro.upload.maximum_size=28672
|
||||
@ -308,9 +349,16 @@ micro.build.extra_flags={build.usb_flags}
|
||||
|
||||
esplora.name=Arduino Esplora
|
||||
esplora.vid.0=0x2341
|
||||
esplora.pid.0=0x003c
|
||||
esplora.pid.0=0x003C
|
||||
esplora.vid.1=0x2341
|
||||
esplora.pid.1=0x803c
|
||||
esplora.pid.1=0x803C
|
||||
esplora.vid.2=0x2A03
|
||||
esplora.pid.2=0x003C
|
||||
esplora.vid.3=0x2A03
|
||||
esplora.pid.3=0x803C
|
||||
|
||||
esplora.vid.0x2A03.warning=Uncertified
|
||||
|
||||
esplora.upload.tool=avrdude
|
||||
esplora.upload.protocol=avr109
|
||||
esplora.upload.maximum_size=28672
|
||||
@ -477,6 +525,10 @@ bt.menu.cpu.atmega168.build.mcu=atmega168
|
||||
##############################################################
|
||||
|
||||
LilyPadUSB.name=LilyPad Arduino USB
|
||||
LilyPadUSB.vid.0=0x1B4F
|
||||
LilyPadUSB.pid.0=0x9207
|
||||
LilyPadUSB.vid.1=0x1B4F
|
||||
LilyPadUSB.pid.1=0x9208
|
||||
|
||||
LilyPadUSB.upload.tool=avrdude
|
||||
LilyPadUSB.upload.protocol=avr109
|
||||
@ -678,6 +730,17 @@ atmegang.menu.cpu.atmega8.build.mcu=atmega8
|
||||
##############################################################
|
||||
|
||||
robotControl.name=Arduino Robot Control
|
||||
robotControl.vid.0=0x2341
|
||||
robotControl.pid.0=0x0038
|
||||
robotControl.vid.1=0x2341
|
||||
robotControl.pid.1=0x8038
|
||||
robotControl.vid.2=0x2A03
|
||||
robotControl.pid.2=0x0038
|
||||
robotControl.vid.3=0x2A03
|
||||
robotControl.pid.3=0x8038
|
||||
|
||||
robotControl.vid.0x2A03.warning=Uncertified
|
||||
|
||||
robotControl.upload.tool=avrdude
|
||||
robotControl.upload.protocol=avr109
|
||||
robotControl.upload.maximum_size=28672
|
||||
@ -708,6 +771,17 @@ robotControl.build.extra_flags={build.usb_flags}
|
||||
##############################################################
|
||||
|
||||
robotMotor.name=Arduino Robot Motor
|
||||
robotMotor.vid.0=0x2341
|
||||
robotMotor.pid.0=0x0039
|
||||
robotMotor.vid.1=0x2341
|
||||
robotMotor.pid.1=0x8039
|
||||
robotMotor.vid.2=0x2A03
|
||||
robotMotor.pid.2=0x0039
|
||||
robotMotor.vid.3=0x2A03
|
||||
robotMotor.pid.3=0x8039
|
||||
|
||||
robotMotor.vid.0x2A03.warning=Uncertified
|
||||
|
||||
robotMotor.upload.tool=avrdude
|
||||
robotMotor.upload.protocol=avr109
|
||||
robotMotor.upload.maximum_size=28672
|
||||
|
@ -98,5 +98,5 @@ tools.avrdude.bootloader.pattern="{cmd.path}" "-C{config.path}" {bootloader.verb
|
||||
# USB Default Flags
|
||||
# Default blank usb manufacturer will be filled it at compile time
|
||||
# - from numeric vendor ID, set to Unknown otherwise
|
||||
build.usb_manufacturer=
|
||||
build.usb_manufacturer="Unknown"
|
||||
build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}'
|
||||
|
@ -2,6 +2,9 @@
|
||||
arduino_due_x_dbg.name=Arduino Due (Programming Port)
|
||||
arduino_due_x_dbg.vid.0=0x2341
|
||||
arduino_due_x_dbg.pid.0=0x003d
|
||||
arduino_due_x_dbg.vid.1=0x2A03
|
||||
arduino_due_x_dbg.pid.1=0x003d
|
||||
arduino_due_x_dbg.vid.0x2A03.warning=Uncertified
|
||||
arduino_due_x_dbg.upload.tool=bossac
|
||||
arduino_due_x_dbg.upload.protocol=sam-ba
|
||||
arduino_due_x_dbg.upload.maximum_size=524288
|
||||
@ -23,6 +26,9 @@ arduino_due_x_dbg.build.pid=0x003e
|
||||
arduino_due_x.name=Arduino Due (Native USB Port)
|
||||
arduino_due_x.vid.0=0x2341
|
||||
arduino_due_x.pid.0=0x003e
|
||||
arduino_due_x.vid.1=0x2A03
|
||||
arduino_due_x.pid.1=0x003e
|
||||
arduino_due_x.vid.0x2A03.warning=Uncertified
|
||||
arduino_due_x.upload.tool=bossac
|
||||
arduino_due_x.upload.protocol=sam-ba
|
||||
arduino_due_x.upload.maximum_size=524288
|
||||
|
Loading…
x
Reference in New Issue
Block a user