mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-29 18:52:13 +01:00
updated code to reflect upstream API changes
This commit is contained in:
parent
0c03dc8db9
commit
2f5d71fb59
@ -32,6 +32,7 @@ import javax.swing.UIManager;
|
||||
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
import processing.app.debug.TargetBoard;
|
||||
import processing.app.debug.TargetPackage;
|
||||
import processing.app.debug.TargetPlatform;
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
@ -147,14 +148,14 @@ public class Platform {
|
||||
protected String resolveDeviceByVendorIdProductId(Map<String, TargetPackage> packages, String readVIDPID) {
|
||||
for (TargetPackage targetPackage : packages.values()) {
|
||||
for (TargetPlatform targetPlatform : targetPackage.getPlatforms().values()) {
|
||||
for (PreferencesMap board : targetPlatform.getBoards().values()) {
|
||||
List<String> vids = new LinkedList<String>(board.createSubTree("vid").values());
|
||||
for (TargetBoard board : targetPlatform.getBoards().values()) {
|
||||
List<String> vids = new LinkedList<String>(board.getPreferences().subTree("vid").values());
|
||||
if (!vids.isEmpty()) {
|
||||
List<String> pids = new LinkedList<String>(board.createSubTree("pid").values());
|
||||
List<String> pids = new LinkedList<String>(board.getPreferences().subTree("pid").values());
|
||||
for (int i = 0; i< vids.size(); i++) {
|
||||
String vidPid = vids.get(i) + "_" + pids.get(i);
|
||||
if (vidPid.toUpperCase().equals(readVIDPID)) {
|
||||
return board.get("name");
|
||||
return board.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,8 @@ public class UploaderFactory {
|
||||
|
||||
private static final Pattern IPV4_ADDRESS = Pattern.compile("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}");
|
||||
|
||||
public Uploader newUploader(Map<String, String> preferences, String port) {
|
||||
if ("true".equals(preferences.get("upload.via_http")) && IPV4_ADDRESS.matcher(port).find()) {
|
||||
public Uploader newUploader(TargetBoard board, String port) {
|
||||
if ("true".equals(board.getPreferences().get("upload.via_http")) && IPV4_ADDRESS.matcher(port).find()) {
|
||||
return new HttpUploader(port);
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package processing.app.debug;
|
||||
|
||||
import org.junit.Test;
|
||||
import processing.app.AbstractWithPreferencesTest;
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -14,7 +15,8 @@ public class UploaderFactoryTest extends AbstractWithPreferencesTest {
|
||||
public void shouldCreateAnInstanceOfHttpUploader() throws Exception {
|
||||
Map<String, String> prefs = new HashMap<String, String>();
|
||||
prefs.put("upload.via_http", "true");
|
||||
Uploader uploader = new UploaderFactory().newUploader(prefs, "192.168.0.1 (mydogstick)");
|
||||
TargetBoard board = new TargetBoard("dummy", new PreferencesMap(prefs), null);
|
||||
Uploader uploader = new UploaderFactory().newUploader(board, "192.168.0.1 (mydogstick)");
|
||||
|
||||
assertTrue(uploader instanceof HttpUploader);
|
||||
}
|
||||
@ -22,7 +24,8 @@ public class UploaderFactoryTest extends AbstractWithPreferencesTest {
|
||||
@Test
|
||||
public void shouldCreateAnInstanceOfBasicUploaderWhenHTTPIsUnsupported() throws Exception {
|
||||
Map<String, String> prefs = new HashMap<String, String>();
|
||||
Uploader uploader = new UploaderFactory().newUploader(prefs, "192.168.0.1 (mydogstick)");
|
||||
TargetBoard board = new TargetBoard("dummy", new PreferencesMap(prefs), null);
|
||||
Uploader uploader = new UploaderFactory().newUploader(board, "192.168.0.1 (mydogstick)");
|
||||
|
||||
assertTrue(uploader instanceof BasicUploader);
|
||||
}
|
||||
@ -30,7 +33,8 @@ public class UploaderFactoryTest extends AbstractWithPreferencesTest {
|
||||
@Test
|
||||
public void shouldCreateAnInstanceOfBasicUploaderWhenPortIsSerial() throws Exception {
|
||||
Map<String, String> prefs = new HashMap<String, String>();
|
||||
Uploader uploader = new UploaderFactory().newUploader(prefs, "/dev/ttyACM0 (Arduino Leonardo)");
|
||||
TargetBoard board = new TargetBoard("dummy", new PreferencesMap(prefs), null);
|
||||
Uploader uploader = new UploaderFactory().newUploader(board, "/dev/ttyACM0 (Arduino Leonardo)");
|
||||
|
||||
assertTrue(uploader instanceof BasicUploader);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user