added a set of new mspsim-based mote types using CC1120, CC1101 and the Enc28j60 ethernet chip

minor changes: removed some obsolete stack monitoring code, improved mspsim-cooja window handler
integration
This commit is contained in:
Fredrik Osterlind 2013-08-15 11:46:29 +02:00
parent ba39d98a86
commit 92655159c8
4 changed files with 83 additions and 54 deletions

View File

@ -1,3 +1,3 @@
se.sics.cooja.GUI.MOTETYPES = + se.sics.cooja.mspmote.ESBMoteType se.sics.cooja.mspmote.SkyMoteType se.sics.cooja.mspmote.Z1MoteType se.sics.cooja.mspmote.WismoteMoteType se.sics.cooja.mspmote.Exp5438MoteType
se.sics.cooja.GUI.MOTETYPES = + se.sics.cooja.mspmote.ESBMoteType se.sics.cooja.mspmote.SkyMoteType se.sics.cooja.mspmote.Z1MoteType se.sics.cooja.mspmote.WismoteMoteType se.sics.cooja.mspmote.Exp5438MoteType se.sics.cooja.mspmote.SkyMoteType com.thingsquare.cooja.mspsim.CC430MoteType com.thingsquare.cooja.mspsim.Exp1120MoteType com.thingsquare.cooja.mspsim.Exp1101MoteType com.thingsquare.cooja.mspsim.Exp2420MoteType com.thingsquare.cooja.mspsim.Trxeb2520MoteType com.thingsquare.cooja.mspsim.Trxeb1120MoteType com.thingsquare.cooja.mspsim.Eth1120MoteType
se.sics.cooja.GUI.JARFILES = + cooja_mspsim.jar mspsim.jar coffee.jar jipv6.jar
se.sics.cooja.GUI.PLUGINS = + se.sics.cooja.mspmote.plugins.MspCLI se.sics.cooja.mspmote.plugins.MspCodeWatcher se.sics.cooja.mspmote.plugins.MspStackWatcher se.sics.cooja.mspmote.plugins.MspCycleWatcher

View File

@ -34,7 +34,12 @@ import java.io.File;
import org.apache.log4j.Logger;
import se.sics.cooja.Simulation;
import se.sics.mspsim.platform.GenericNode;
import se.sics.mspsim.platform.ti.Exp1101Node;
import se.sics.mspsim.platform.ti.Exp1120Node;
import se.sics.mspsim.platform.ti.Exp5438Node;
import se.sics.mspsim.platform.ti.Trxeb1120Node;
import se.sics.mspsim.platform.ti.Trxeb2520Node;
/**
* @author Fredrik Osterlind
@ -42,15 +47,39 @@ import se.sics.mspsim.platform.ti.Exp5438Node;
public class Exp5438Mote extends MspMote {
private static Logger logger = Logger.getLogger(Exp5438Mote.class);
public Exp5438Node exp5438Node = null;
public GenericNode exp5438Node = null;
private String desc = "";
public Exp5438Mote(MspMoteType moteType, Simulation sim) {
super(moteType, sim);
}
protected boolean initEmulator(File fileELF) {
/* Hack: Try to figure out what type of Mspsim-node we should be used by checking file extension */
String filename = fileELF.getName();
if (filename.endsWith(".exp1101")) {
exp5438Node = new Exp1101Node();
desc = "Exp5438+CC1101";
} else if (filename.endsWith(".exp1120")) {
exp5438Node = new Exp1120Node();
desc = "Exp5438+CC1120";
} else if (filename.endsWith(".trxeb2520")) {
exp5438Node = new Trxeb2520Node();
desc = "Trxeb2520";
} else if (filename.endsWith(".trxeb1120")) {
exp5438Node = new Trxeb1120Node(false);
desc = "Trxeb1120";
} else if (filename.endsWith(".eth1120")) {
exp5438Node = new Trxeb1120Node(true);
desc = "Eth1120";
} else if (filename.endsWith(".exp2420") || filename.endsWith(".exp5438")) {
exp5438Node = new Exp5438Node();
desc = "Exp5438+CC2420";
} else {
throw new IllegalStateException("unknown file extension, cannot figure out what Mspsim node type to use: " + filename);
}
try {
exp5438Node = new Exp5438Node();
registry = exp5438Node.getRegistry();
prepareMote(fileELF, exp5438Node);
} catch (Exception e) {
@ -64,7 +93,7 @@ public class Exp5438Mote extends MspMote {
}
public String toString() {
return "Exp5438 " + getID();
return desc + " " + getID();
}
}

View File

@ -62,6 +62,9 @@ import se.sics.cooja.mspmote.interfaces.MspDebugOutput;
import se.sics.cooja.mspmote.interfaces.MspMoteID;
import se.sics.cooja.mspmote.interfaces.UsciA1Serial;
import com.thingsquare.cooja.mspsim.CC1101Radio;
import com.thingsquare.cooja.mspsim.CC1120Radio;
@ClassDescription("EXP430F5438 mote")
@AbstractionLevelDescription("Emulated level")
public class Exp5438MoteType extends MspMoteType {

View File

@ -30,13 +30,13 @@
package se.sics.cooja.mspmote;
import java.awt.Component;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Hashtable;
import java.util.Observable;
import org.apache.log4j.Logger;
import org.jdom.Element;
@ -53,8 +53,8 @@ import se.sics.cooja.Watchpoint;
import se.sics.cooja.WatchpointMote;
import se.sics.cooja.interfaces.IPAddress;
import se.sics.cooja.motes.AbstractEmulatedMote;
import se.sics.cooja.mspmote.interfaces.MspSerial;
import se.sics.cooja.mspmote.interfaces.Msp802154Radio;
import se.sics.cooja.mspmote.interfaces.MspSerial;
import se.sics.cooja.mspmote.plugins.CodeVisualizerSkin;
import se.sics.cooja.mspmote.plugins.MspBreakpoint;
import se.sics.cooja.plugins.Visualizer;
@ -65,7 +65,8 @@ import se.sics.mspsim.cli.LineOutputStream;
import se.sics.mspsim.core.EmulationException;
import se.sics.mspsim.core.MSP430;
import se.sics.mspsim.platform.GenericNode;
import se.sics.mspsim.ui.JFrameWindowManager;
import se.sics.mspsim.ui.ManagedWindow;
import se.sics.mspsim.ui.WindowManager;
import se.sics.mspsim.util.ComponentRegistry;
import se.sics.mspsim.util.ConfigManager;
import se.sics.mspsim.util.DebugInfo;
@ -95,10 +96,8 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
/* Stack monitoring variables */
private boolean stopNextInstruction = false;
private boolean monitorStackUsage = false;
private int stackPointerLow = Integer.MAX_VALUE;
private int heapStartAddress;
private StackOverflowObservable stackOverflowObservable = new StackOverflowObservable();
public GenericNode mspNode = null;
public MspMote(MspMoteType moteType, Simulation simulation) {
this.simulation = simulation;
@ -113,8 +112,43 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
initEmulator(myMoteType.getContikiFirmwareFile());
myMoteInterfaceHandler = createMoteInterfaceHandler();
/* TODO Setup COOJA-specific window manager */
registry.registerComponent("windowManager", new JFrameWindowManager());
/* TODO Create COOJA-specific window manager */
registry.removeComponent("windowManager");
registry.registerComponent("windowManager", new WindowManager() {
public ManagedWindow createWindow(String name) {
return new ManagedWindow() {
public void setVisible(boolean b) {
logger.warn("setVisible() ignored");
}
public void setTitle(String string) {
logger.warn("setTitle() ignored");
}
public void setSize(int width, int height) {
logger.warn("setSize() ignored");
}
public void setBounds(int x, int y, int width, int height) {
logger.warn("setBounds() ignored");
}
public void removeAll() {
logger.warn("removeAll() ignored");
}
public void pack() {
logger.warn("pack() ignored");
}
public boolean isVisible() {
logger.warn("isVisible() return false");
return false;
}
public String getTitle() {
logger.warn("getTitle() return \"\"");
return "";
}
public void add(Component component) {
logger.warn("add() ignored");
}
};
}
});
try {
debuggingInfo = ((MspMoteType)getType()).getFirmwareDebugInfo();
@ -156,45 +190,6 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
myMemory = (MspMoteMemory) memory;
}
/* Stack monitoring variables */
public class StackOverflowObservable extends Observable {
public void signalStackOverflow() {
setChanged();
notifyObservers();
}
}
/**
* Enable/disable stack monitoring
*
* @param monitoring Monitoring enabled
*/
public void monitorStack(boolean monitoring) {
this.monitorStackUsage = monitoring;
resetLowestStackPointer();
}
/**
* @return Lowest SP since stack monitoring was enabled
*/
public int getLowestStackPointer() {
return stackPointerLow;
}
/**
* Resets lowest stack pointer variable
*/
public void resetLowestStackPointer() {
stackPointerLow = Integer.MAX_VALUE;
}
/**
* @return Stack overflow observable
*/
public StackOverflowObservable getStackOverflowObservable() {
return stackOverflowObservable;
}
/**
* Prepares CPU, memory and ELF module.
*
@ -204,6 +199,9 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
*/
protected void prepareMote(File fileELF, GenericNode node) throws IOException {
this.commandHandler = new CommandHandler(System.out, System.err);
this.mspNode = node;
node.setCommandHandler(commandHandler);
ConfigManager config = new ConfigManager();
@ -225,7 +223,6 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
MapEntry[] allEntries = map.getAllEntries();
myMemory = new MspMoteMemory(this, allEntries, myCpu);
heapStartAddress = map.heapStartAddress;
myCpu.reset();
}