removed contiki motes' communication stack configuration; the network stack instead depends on compiler flags/contiki-conf.h

This commit is contained in:
fros4943 2010-03-10 07:49:25 +00:00
parent 98929bd2f5
commit 70dd5454fc
3 changed files with 59 additions and 61 deletions

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: ContikiMoteType.java,v 1.40 2010/03/09 08:09:57 fros4943 Exp $ * $Id: ContikiMoteType.java,v 1.41 2010/03/10 07:52:05 fros4943 Exp $
*/ */
package se.sics.cooja.contikimote; package se.sics.cooja.contikimote;
@ -124,48 +124,49 @@ public class ContikiMoteType implements MoteType {
/** /**
* Communication stacks in Contiki. * Communication stacks in Contiki.
*/ */
public enum CommunicationStack { public enum NetworkStack {
RIME, UIP, UIPV6; DEFAULT, MANUAL;
public String manualHeader = "netstack-conf-example.h";
public String toString() { public String toString() {
if (this == UIPV6) { if (this == DEFAULT) {
return "uIPv6"; return "Default (from contiki-conf.h)";
} } else if (this == MANUAL) {
if (this == UIP) { return "Manual netstack header";
return "uIPv4";
}
if (this == RIME) {
return "Rime";
} }
return "[unknown]"; return "[unknown]";
} }
public String getSourceFilenamesString() { public String getHeaderFile() {
// if (this == UIPV6) { if (this == DEFAULT) {
// return " init-net-uipv6.c"; return null;
// } } else if (this == MANUAL) {
// if (this == UIP) { return manualHeader;
// return " init-net-uip.c"; }
// } return null;
// if (this == RIME) {
// return " init-net-rime.c";
// }
return " ";
} }
public static CommunicationStack parse(String name) { public String getConfig() {
if (name.equals("uIPv4") || name.equals("UIP")) { if (this == DEFAULT) {
return UIP; return "DEFAULT";
} else if (this == MANUAL) {
return "MANUAL:" + manualHeader;
} }
if (name.equals("uIPv6") || name.equals("UIPV6")) { return "[unknown]";
return UIPV6;
}
if (name.equals("Rime") || name.equals("RIME")) {
return RIME;
} }
logger.warn("Can't parse communication stack name: " + name); public static NetworkStack parseConfig(String config) {
return RIME; if (config.equals("DEFAULT")) {
return DEFAULT;
} else if (config.startsWith("MANUAL")) {
NetworkStack st = MANUAL;
st.manualHeader = config.split(":")[1];
return st;
}
/* TODO Backwards compatibility */
logger.warn("Bad network stack config: '" + config + "', using default");
return DEFAULT;
} }
} }
@ -191,7 +192,7 @@ public class ContikiMoteType implements MoteType {
private boolean hasSystemSymbols = false; private boolean hasSystemSymbols = false;
private CommunicationStack commStack = CommunicationStack.RIME; private NetworkStack netStack = NetworkStack.DEFAULT;
private Simulation simulation = null; private Simulation simulation = null;
@ -292,8 +293,7 @@ public class ContikiMoteType implements MoteType {
contikiApp, contikiApp,
mapFile, mapFile,
libFile, libFile,
archiveFile, archiveFile);
commStack);
} catch (Exception e) { } catch (Exception e) {
throw (MoteTypeCreationException) new MoteTypeCreationException( throw (MoteTypeCreationException) new MoteTypeCreationException(
"Error when creating environment: " + e.getMessage()).initCause(e); "Error when creating environment: " + e.getMessage()).initCause(e);
@ -665,17 +665,17 @@ public class ContikiMoteType implements MoteType {
} }
/** /**
* @param commStack Communication stack * @param netStack Contiki network stack
*/ */
public void setCommunicationStack(CommunicationStack commStack) { public void setNetworkStack(NetworkStack netStack) {
this.commStack = commStack; this.netStack = netStack;
} }
/** /**
* @return Contiki communication stack * @return Contiki network stack
*/ */
public CommunicationStack getCommunicationStack() { public NetworkStack getNetworkStack() {
return commStack; return netStack;
} }
/** /**
@ -1257,9 +1257,11 @@ public class ContikiMoteType implements MoteType {
element.setText(new Boolean(hasSystemSymbols()).toString()); element.setText(new Boolean(hasSystemSymbols()).toString());
config.add(element); config.add(element);
element = new Element("commstack"); if (getNetworkStack() != NetworkStack.DEFAULT) {
element.setText(getCommunicationStack().toString()); element = new Element("netstack");
element.setText(getNetworkStack().getConfig());
config.add(element); config.add(element);
}
return config; return config;
} }
@ -1299,7 +1301,11 @@ public class ContikiMoteType implements MoteType {
} else if (name.equals("symbols")) { } else if (name.equals("symbols")) {
hasSystemSymbols = Boolean.parseBoolean(element.getText()); hasSystemSymbols = Boolean.parseBoolean(element.getText());
} else if (name.equals("commstack")) { } else if (name.equals("commstack")) {
commStack = CommunicationStack.parse(element.getText()); logger.warn("COOJA's communication stack config was removed: " + element.getText());
logger.warn("Instead assuming default network stack.");
netStack = NetworkStack.DEFAULT;
} else if (name.equals("netstack")) {
netStack = NetworkStack.parseConfig(element.getText());
} else if (name.equals("moteinterface")) { } else if (name.equals("moteinterface")) {
if (element.getText().trim().equals("se.sics.cooja.contikimote.interfaces.ContikiLog")) { if (element.getText().trim().equals("se.sics.cooja.contikimote.interfaces.ContikiLog")) {
/* Backwards compatibility: ContikiLog was removed */ /* Backwards compatibility: ContikiLog was removed */

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: CompileContiki.java,v 1.4 2009/04/01 14:00:00 fros4943 Exp $ * $Id: CompileContiki.java,v 1.5 2010/03/10 07:49:25 fros4943 Exp $
*/ */
package se.sics.cooja.dialogs; package se.sics.cooja.dialogs;
@ -42,6 +42,7 @@ import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.Reader; import java.io.Reader;
import javax.swing.Action; import javax.swing.Action;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -49,8 +50,6 @@ import org.apache.log4j.Logger;
import se.sics.cooja.GUI; import se.sics.cooja.GUI;
import se.sics.cooja.MoteType.MoteTypeCreationException; import se.sics.cooja.MoteType.MoteTypeCreationException;
import se.sics.cooja.contikimote.ContikiMoteType; import se.sics.cooja.contikimote.ContikiMoteType;
import se.sics.cooja.contikimote.ContikiMoteType.CommunicationStack;
import se.sics.cooja.dialogs.MessageList;
/** /**
* Contiki compiler library. * Contiki compiler library.
@ -377,8 +376,7 @@ public class CompileContiki {
File contikiApp, File contikiApp,
File mapFile, File mapFile,
File libFile, File libFile,
File archiveFile, File archiveFile)
CommunicationStack commStack)
throws Exception { throws Exception {
if (identifier == null) { if (identifier == null) {
@ -397,7 +395,6 @@ public class CompileContiki {
throw new Exception("No archive file specified"); throw new Exception("No archive file specified");
} }
String[][] env = new String[13][];
boolean includeSymbols = false; /* TODO */ boolean includeSymbols = false; /* TODO */
/* Fetch configuration from external tools */ /* Fetch configuration from external tools */
@ -440,14 +437,11 @@ public class CompileContiki {
ccFlags = ccFlags.replace("$(JAVA_HOME)", javaHome); ccFlags = ccFlags.replace("$(JAVA_HOME)", javaHome);
/* Strip away contiki application .c extension */ /* Strip away contiki application .c extension */
String commStackFiles = "";
if (commStack != null) {
commStackFiles = commStack.getSourceFilenamesString();
}
String contikiAppNoExtension = contikiApp.getName().substring(0, contikiApp.getName().length()-2); String contikiAppNoExtension = contikiApp.getName().substring(0, contikiApp.getName().length()-2);
String[][] env = new String[13][];
env[0] = new String[] { "LIBNAME", identifier }; env[0] = new String[] { "LIBNAME", identifier };
env[1] = new String[] { "CONTIKI_APP", contikiAppNoExtension }; env[1] = new String[] { "CONTIKI_APP", contikiAppNoExtension };
env[2] = new String[] { "COOJA_SOURCEFILES", commStackFiles }; env[2] = new String[] { "COOJA_SOURCEFILES", "" };
env[3] = new String[] { "CC", GUI.getExternalToolsSetting("PATH_C_COMPILER") }; env[3] = new String[] { "CC", GUI.getExternalToolsSetting("PATH_C_COMPILER") };
env[4] = new String[] { "EXTRA_CC_ARGS", ccFlags }; env[4] = new String[] { "EXTRA_CC_ARGS", ccFlags };
env[5] = new String[] { "LD", GUI.getExternalToolsSetting("PATH_LINKER") }; env[5] = new String[] { "LD", GUI.getExternalToolsSetting("PATH_LINKER") };

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: ConfigurationWizard.java,v 1.7 2010/02/03 15:49:24 fros4943 Exp $ * $Id: ConfigurationWizard.java,v 1.8 2010/03/10 07:49:46 fros4943 Exp $
*/ */
package se.sics.cooja.dialogs; package se.sics.cooja.dialogs;
@ -69,7 +69,6 @@ import se.sics.cooja.GUI;
import se.sics.cooja.SectionMoteMemory; import se.sics.cooja.SectionMoteMemory;
import se.sics.cooja.MoteType.MoteTypeCreationException; import se.sics.cooja.MoteType.MoteTypeCreationException;
import se.sics.cooja.contikimote.ContikiMoteType; import se.sics.cooja.contikimote.ContikiMoteType;
import se.sics.cooja.contikimote.ContikiMoteType.CommunicationStack;
/* TODO Test common section */ /* TODO Test common section */
@ -602,8 +601,7 @@ public class ConfigurationWizard extends JDialog {
new File(cLibraryName + ".c"), new File(cLibraryName + ".c"),
new File(cLibraryName + ContikiMoteType.mapSuffix), new File(cLibraryName + ContikiMoteType.mapSuffix),
new File(cLibraryName + ContikiMoteType.librarySuffix), new File(cLibraryName + ContikiMoteType.librarySuffix),
new File(cLibraryName + ContikiMoteType.dependSuffix), new File(cLibraryName + ContikiMoteType.dependSuffix)
CommunicationStack.RIME
); );
} catch (Exception e) { } catch (Exception e) {
testOutput.addMessage("### Error: Compiler environment failed", MessageList.ERROR); testOutput.addMessage("### Error: Compiler environment failed", MessageList.ERROR);