1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-04-05 21:40:24 +02:00

boards.txt modified. java code updated

This commit is contained in:
Federico Fissore 2013-04-16 09:18:00 +02:00
parent 09f643972c
commit 0b8489d31e
4 changed files with 41 additions and 17 deletions

View File

@ -1661,7 +1661,7 @@ public class Sketch {
TargetPlatform target = Base.getTargetPlatform(); TargetPlatform target = Base.getTargetPlatform();
String board = Preferences.get("board"); String board = Preferences.get("board");
Uploader uploader = new UploaderFactory().newUploader(target.getBoards().get(board)); Uploader uploader = new UploaderFactory().newUploader(target.getBoards().get(board), Preferences.get("serial.port"));
boolean success = uploader.uploadUsingPreferences(buildPath, suggestedClassName, usingProgrammer); boolean success = uploader.uploadUsingPreferences(buildPath, suggestedClassName, usingProgrammer);

View File

@ -1,15 +1,14 @@
package processing.app.debug; package processing.app.debug;
import processing.app.Base;
import processing.app.Preferences;
import processing.app.helpers.Maps;
import java.util.Map; import java.util.Map;
import java.util.regex.Pattern;
public class UploaderFactory { public class UploaderFactory {
public Uploader newUploader(Map<String, String> preferences) { private static final Pattern IPV4_ADDRESS = Pattern.compile("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}");
if ("http".equals(preferences.get("upload.tool"))) {
public Uploader newUploader(Map<String, String> preferences, String port) {
if ("true".equals(preferences.get("upload.via_http")) && IPV4_ADDRESS.matcher(port).find()) {
return new HttpUploader(); return new HttpUploader();
} }

View File

@ -13,17 +13,24 @@ public class UploaderFactoryTest extends AbstractWithPreferencesTest {
@Test @Test
public void shouldCreateAnInstanceOfHttpUploader() throws Exception { public void shouldCreateAnInstanceOfHttpUploader() throws Exception {
Map<String, String> prefs = new HashMap<String, String>(); Map<String, String> prefs = new HashMap<String, String>();
prefs.put("upload.tool", "http"); prefs.put("upload.via_http", "true");
Uploader uploader = new UploaderFactory().newUploader(prefs); Uploader uploader = new UploaderFactory().newUploader(prefs, "192.168.0.1 (mydogstick)");
assertTrue(uploader instanceof HttpUploader); assertTrue(uploader instanceof HttpUploader);
} }
@Test @Test
public void shouldCreateAnInstanceOfBasicUploader() throws Exception { public void shouldCreateAnInstanceOfBasicUploaderWhenHTTPIsUnsupported() throws Exception {
Map<String, String> prefs = new HashMap<String, String>(); Map<String, String> prefs = new HashMap<String, String>();
prefs.put("upload.tool", "whatever"); Uploader uploader = new UploaderFactory().newUploader(prefs, "192.168.0.1 (mydogstick)");
Uploader uploader = new UploaderFactory().newUploader(prefs);
assertTrue(uploader instanceof BasicUploader);
}
@Test
public void shouldCreateAnInstanceOfBasicUploaderWhenPortIsSerial() throws Exception {
Map<String, String> prefs = new HashMap<String, String>();
Uploader uploader = new UploaderFactory().newUploader(prefs, "/dev/ttyACM0 (Arduino Leonardo)");
assertTrue(uploader instanceof BasicUploader); assertTrue(uploader instanceof BasicUploader);
} }

View File

@ -4,14 +4,32 @@ menu.cpu=Processor
############################################################## ##############################################################
dogstick.name=Arduino Dogstick dogstick.name=Arduino DogStick
dogstick.upload.tool=http dogstick.upload.via_http=true
dogstick.upload.tool=avrdude
dogstick.upload.protocol=avr109
dogstick.upload.maximum_size=28672
dogstick.upload.speed=57600
dogstick.upload.disable_flushing=true
dogstick.upload.use_1200bps_touch=true
dogstick.upload.wait_for_upload_port=true
dogstick.build.mcu=atmega328p dogstick.bootloader.tool=avrdude
dogstick.bootloader.low_fuses=0xff
dogstick.bootloader.high_fuses=0xd8
dogstick.bootloader.extended_fuses=0xcb
dogstick.bootloader.file=caterina/Caterina-Leonardo.hex
dogstick.bootloader.unlock_bits=0x3F
dogstick.bootloader.lock_bits=0x2F
dogstick.build.mcu=atmega32u4
dogstick.build.f_cpu=16000000L dogstick.build.f_cpu=16000000L
dogstick.build.board=ARDUINO_UNO dogstick.build.vid=0x2341
dogstick.build.pid=0x8036
dogstick.build.board=ARDUINO_DOGSTICK
dogstick.build.core=arduino dogstick.build.core=arduino
dogstick.build.variant=standard dogstick.build.variant=leonardo
dogstick.build.extra_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid}
############################################################## ##############################################################