From dbf2fbd23e048e9f66c29ba73ee8ccc936d7fee4 Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Wed, 21 Aug 2013 00:51:00 +0200 Subject: [PATCH] Guess platform based on firmware filename suffix --- Makefile | 2 +- build.xml | 7 ++++++- se/sics/mspsim/Main.java | 20 +++++++++++++++----- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 4891da8..6c4611c 100644 --- a/Makefile +++ b/Makefile @@ -128,7 +128,7 @@ help: @echo "Usage: make [all,compile,clean,run,runsky,runesb]" run: compile - $(JAVA) $(JAVAARGS) se.sics.mspsim.util.IHexReader $(ARGS) $(FIRMWAREFILE) $(MAPFILE) + $(JAVA) $(JAVAARGS) se.sics.mspsim.Main $(ARGS) $(FIRMWAREFILE) $(MAPFILE) runesb: compile $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.esb.ESBNode $(ARGS) $(ESBFIRMWARE) $(MAPFILE) diff --git a/build.xml b/build.xml index b50c524..ed932f9 100644 --- a/build.xml +++ b/build.xml @@ -94,7 +94,12 @@ - + + + + + + diff --git a/se/sics/mspsim/Main.java b/se/sics/mspsim/Main.java index 31b73a9..7270aac 100644 --- a/se/sics/mspsim/Main.java +++ b/se/sics/mspsim/Main.java @@ -28,16 +28,12 @@ * * This file is part of MSPSim. * - * $Id$ - * * ----------------------------------------------------------------- * * Main * * Authors : Joakim Eriksson, Niclas Finne * Created : 6 nov 2008 - * Updated : $Date$ - * $Revision$ */ package se.sics.mspsim; @@ -104,7 +100,21 @@ public class Main { if (nodeType != null) { node = createNode(nodeType); } else { - platform = config.getProperty("platform", "sky"); + platform = config.getProperty("platform"); + if (platform == null) { + // Default platform + platform = "sky"; + + // Guess platform based on firmware filename suffix. + // TinyOS firmware files are often named 'main.exe'. + String[] a = config.getArguments(); + if (a.length > 0 && !"main.exe".equals(a[0])) { + int index = a[0].lastIndexOf('.'); + if (index > 0) { + platform = a[0].substring(index + 1); + } + } + } nodeType = getNodeTypeByPlatform(platform); node = createNode(nodeType); }