Merge branch 'contiki'

Conflicts:
	cpu/cc26xx-cc13xx/lib/cc13xxware
	cpu/cc26xx-cc13xx/lib/cc26xxware
This commit is contained in:
Harald Pichler 2017-01-31 15:00:59 +01:00
commit 2f8549aaae
319 changed files with 58114 additions and 6745 deletions

View file

@ -189,7 +189,6 @@ contiki-atari-1.atr: atarixl-makes
cp ../../examples/webbrowser/webbrowser.atarixl atr/webbrows.com
cp ../../examples/wget/wget.atarixl atr/wget.com
cp ../atarixl/default.cfg atr/contiki.cfg
cp ../../cpu/6502/ethconfig/cs8900a.eth atr/cs8900a.eth
cp $(CC65)/atarixl/drv/mou/atrxst.mou atr/contiki.mou
cp $(CC65)/atarixl/drv/mou/atrxami.mou atr/ami.mou
cp $(CC65)/atarixl/drv/mou/atrxjoy.mou atr/joy.mou
@ -205,7 +204,6 @@ contiki-atari-2.atr: atarixl-makes
cp ../../cpu/6502/ipconfig/ipconfig.atarixl atr/ipconfig.com
cp ../../examples/irc/irc-client.atarixl atr/irc.com
cp ../atarixl/default.cfg atr/contiki.cfg
cp ../../cpu/6502/ethconfig/cs8900a.eth atr/cs8900a.eth
cp $(CC65)/atarixl/drv/mou/atrxst.mou atr/contiki.mou
cp $(CC65)/atarixl/drv/mou/atrxami.mou atr/ami.mou
cp $(CC65)/atarixl/drv/mou/atrxjoy.mou atr/joy.mou
@ -222,7 +220,6 @@ contiki-atari-3.atr: atarixl-makes
cp ../../examples/webserver/webserver-example.atarixl atr/webserv.com
cp ../../examples/telnet-server/telnet-server.atarixl atr/telnetd.com
cp ../atarixl/default.cfg atr/contiki.cfg
cp ../../cpu/6502/ethconfig/cs8900a.eth atr/cs8900a.eth
cp $(CC65)/atarixl/drv/mou/atrxst.mou atr/contiki.mou
cp $(CC65)/atarixl/drv/mou/atrxami.mou atr/ami.mou
cp $(CC65)/atarixl/drv/mou/atrxjoy.mou atr/joy.mou
@ -246,7 +243,6 @@ contiki-atari.atr: atarixl-makes
cp ../../examples/webserver/webserver-example.atarixl atr/webserv.com
cp ../../examples/telnet-server/telnet-server.atarixl atr/telnetd.com
cp ../atarixl/default.cfg atr/contiki.cfg
cp ../../cpu/6502/ethconfig/cs8900a.eth atr/cs8900a.eth
cp $(CC65)/atarixl/drv/mou/atrxst.mou atr/contiki.mou
cp $(CC65)/atarixl/drv/mou/atrxami.mou atr/ami.mou
cp $(CC65)/atarixl/drv/mou/atrxjoy.mou atr/joy.mou

View file

@ -63,8 +63,6 @@ import org.contikios.cooja.avrmote.interfaces.MicaZLED;
import org.contikios.cooja.avrmote.interfaces.MicaZRadio;
import org.contikios.cooja.dialogs.CompileContiki;
import org.contikios.cooja.dialogs.MessageList;
import org.contikios.cooja.dialogs.MessageListText;
import org.contikios.cooja.dialogs.MessageListUI;
import org.contikios.cooja.dialogs.MessageContainer;
import org.contikios.cooja.interfaces.Mote2MoteRelations;
import org.contikios.cooja.interfaces.MoteAttributes;
@ -366,7 +364,7 @@ public class MicaZMoteType implements MoteType {
throw new MoteTypeCreationException("No identifier");
}
final MessageList compilationOutput = visAvailable ? new MessageListUI() : new MessageListText();
final MessageList compilationOutput = MessageContainer.createMessageList(visAvailable);
if (getCompileCommands() != null) {
/* Handle multiple compilation commands one by one */

View file

@ -81,7 +81,7 @@ public abstract class AbstractMspMoteType extends MspMoteType {
}
/* If visualized, show compile dialog and let user configure */
if (visAvailable) {
if (visAvailable && !simulation.isQuickSetup()) {
/* Create unique identifier */
if (getIdentifier() == null) {
@ -118,7 +118,7 @@ public abstract class AbstractMspMoteType extends MspMoteType {
throw new MoteTypeCreationException("No identifier");
}
final MessageList compilationOutput = visAvailable ? new MessageListUI() : new MessageListText();
final MessageList compilationOutput = MessageContainer.createMessageList(visAvailable);
if (getCompileCommands() != null) {
/* Handle multiple compilation commands one by one */

View file

@ -78,7 +78,7 @@ public class CC430MoteType extends MspMoteType {
throws MoteTypeCreationException {
/* If visualized, show compile dialog and let user configure */
if (visAvailable) {
if (visAvailable && !simulation.isQuickSetup()) {
/* Create unique identifier */
if (getIdentifier() == null) {
@ -115,7 +115,7 @@ public class CC430MoteType extends MspMoteType {
throw new MoteTypeCreationException("No identifier");
}
final MessageList compilationOutput = visAvailable ? new MessageListUI() : new MessageListText();
final MessageList compilationOutput = MessageContainer.createMessageList(visAvailable);
if (getCompileCommands() != null) {
/* Handle multiple compilation commands one by one */

View file

@ -114,7 +114,7 @@ public class ESBMoteType extends MspMoteType {
}
/* If visualized, show compile dialog and let user configure */
if (visAvailable) {
if (visAvailable && !simulation.isQuickSetup()) {
/* Create unique identifier */
if (getIdentifier() == null) {
@ -151,7 +151,7 @@ public class ESBMoteType extends MspMoteType {
throw new MoteTypeCreationException("No identifier");
}
final MessageList compilationOutput = visAvailable ? new MessageListUI() : new MessageListText();
final MessageList compilationOutput = MessageContainer.createMessageList(visAvailable);
if (getCompileCommands() != null) {
/* Handle multiple compilation commands one by one */

View file

@ -36,7 +36,7 @@ public class Eth1120MoteType extends Exp5438MoteType {
throws MoteTypeCreationException {
/* If visualized, show compile dialog and let user configure */
if (visAvailable) {
if (visAvailable && !simulation.isQuickSetup()) {
/* Create unique identifier */
if (getIdentifier() == null) {
@ -73,7 +73,7 @@ public class Eth1120MoteType extends Exp5438MoteType {
throw new MoteTypeCreationException("No identifier");
}
final MessageList compilationOutput = visAvailable ? new MessageListUI() : new MessageListText();
final MessageList compilationOutput = MessageContainer.createMessageList(visAvailable);
if (getCompileCommands() != null) {
/* Handle multiple compilation commands one by one */

View file

@ -36,7 +36,7 @@ public class Exp1101MoteType extends Exp5438MoteType {
throws MoteTypeCreationException {
/* If visualized, show compile dialog and let user configure */
if (visAvailable) {
if (visAvailable && !simulation.isQuickSetup()) {
/* Create unique identifier */
if (getIdentifier() == null) {
@ -73,7 +73,7 @@ public class Exp1101MoteType extends Exp5438MoteType {
throw new MoteTypeCreationException("No identifier");
}
final MessageList compilationOutput = visAvailable ? new MessageListUI() : new MessageListText();
final MessageList compilationOutput = MessageContainer.createMessageList(visAvailable);
if (getCompileCommands() != null) {
/* Handle multiple compilation commands one by one */

View file

@ -37,7 +37,7 @@ public class Exp1120MoteType extends Exp5438MoteType {
throws MoteTypeCreationException {
/* If visualized, show compile dialog and let user configure */
if (visAvailable) {
if (visAvailable && !simulation.isQuickSetup()) {
/* Create unique identifier */
if (getIdentifier() == null) {
@ -74,7 +74,7 @@ public class Exp1120MoteType extends Exp5438MoteType {
throw new MoteTypeCreationException("No identifier");
}
final MessageList compilationOutput = visAvailable ? new MessageListUI() : new MessageListText();
final MessageList compilationOutput = MessageContainer.createMessageList(visAvailable);
if (getCompileCommands() != null) {
/* Handle multiple compilation commands one by one */

View file

@ -37,7 +37,7 @@ public class Exp2420MoteType extends Exp5438MoteType {
throws MoteTypeCreationException {
/* If visualized, show compile dialog and let user configure */
if (visAvailable) {
if (visAvailable && !simulation.isQuickSetup()) {
/* Create unique identifier */
if (getIdentifier() == null) {
@ -74,7 +74,7 @@ public class Exp2420MoteType extends Exp5438MoteType {
throw new MoteTypeCreationException("No identifier");
}
final MessageList compilationOutput = visAvailable ? new MessageListUI() : new MessageListText();
final MessageList compilationOutput = MessageContainer.createMessageList(visAvailable);
if (getCompileCommands() != null) {
/* Handle multiple compilation commands one by one */

View file

@ -78,7 +78,7 @@ public class Exp5438MoteType extends MspMoteType {
throws MoteTypeCreationException {
/* If visualized, show compile dialog and let user configure */
if (visAvailable) {
if (visAvailable && !simulation.isQuickSetup()) {
/* Create unique identifier */
if (getIdentifier() == null) {
@ -115,7 +115,7 @@ public class Exp5438MoteType extends MspMoteType {
throw new MoteTypeCreationException("No identifier");
}
final MessageList compilationOutput = visAvailable ? new MessageListUI() : new MessageListText();
final MessageList compilationOutput = MessageContainer.createMessageList(visAvailable);
if (getCompileCommands() != null) {
/* Handle multiple compilation commands one by one */

View file

@ -51,8 +51,6 @@ import org.contikios.cooja.MoteType;
import org.contikios.cooja.Simulation;
import org.contikios.cooja.dialogs.CompileContiki;
import org.contikios.cooja.dialogs.MessageList;
import org.contikios.cooja.dialogs.MessageListText;
import org.contikios.cooja.dialogs.MessageListUI;
import org.contikios.cooja.dialogs.MessageContainer;
import org.contikios.cooja.interfaces.IPAddress;
import org.contikios.cooja.interfaces.Mote2MoteRelations;
@ -100,7 +98,7 @@ public class SkyMoteType extends MspMoteType {
}
/* If visualized, show compile dialog and let user configure */
if (visAvailable) {
if (visAvailable && !simulation.isQuickSetup()) {
/* Create unique identifier */
if (getIdentifier() == null) {
@ -137,7 +135,7 @@ public class SkyMoteType extends MspMoteType {
throw new MoteTypeCreationException("No identifier");
}
final MessageList compilationOutput = visAvailable ? new MessageListUI() : new MessageListText();
final MessageList compilationOutput = MessageContainer.createMessageList(visAvailable);
if (getCompileCommands() != null) {
/* Handle multiple compilation commands one by one */

View file

@ -36,7 +36,7 @@ public class Trxeb1120MoteType extends Exp5438MoteType {
throws MoteTypeCreationException {
/* If visualized, show compile dialog and let user configure */
if (visAvailable) {
if (visAvailable && !simulation.isQuickSetup()) {
/* Create unique identifier */
if (getIdentifier() == null) {
@ -73,7 +73,7 @@ public class Trxeb1120MoteType extends Exp5438MoteType {
throw new MoteTypeCreationException("No identifier");
}
final MessageList compilationOutput = visAvailable ? new MessageListUI() : new MessageListText();
final MessageList compilationOutput = MessageContainer.createMessageList(visAvailable);
if (getCompileCommands() != null) {
/* Handle multiple compilation commands one by one */

View file

@ -36,7 +36,7 @@ public class Trxeb2520MoteType extends Exp5438MoteType {
throws MoteTypeCreationException {
/* If visualized, show compile dialog and let user configure */
if (visAvailable) {
if (visAvailable && !simulation.isQuickSetup()) {
/* Create unique identifier */
if (getIdentifier() == null) {
@ -73,7 +73,7 @@ public class Trxeb2520MoteType extends Exp5438MoteType {
throw new MoteTypeCreationException("No identifier");
}
final MessageList compilationOutput = visAvailable ? new MessageListUI() : new MessageListText();
final MessageList compilationOutput = MessageContainer.createMessageList(visAvailable);
if (getCompileCommands() != null) {
/* Handle multiple compilation commands one by one */

View file

@ -77,7 +77,7 @@ public class TyndallMoteType extends MspMoteType {
throws MoteTypeCreationException {
/* If visualized, show compile dialog and let user configure */
if (visAvailable) {
if (visAvailable && !simulation.isQuickSetup()) {
/* Create unique identifier */
if (getIdentifier() == null) {
@ -114,7 +114,7 @@ public class TyndallMoteType extends MspMoteType {
throw new MoteTypeCreationException("No identifier");
}
final MessageList compilationOutput = visAvailable ? new MessageListUI() : new MessageListText();
final MessageList compilationOutput = MessageContainer.createMessageList(visAvailable);
if (getCompileCommands() != null) {
/* Handle multiple compilation commands one by one */

View file

@ -3378,7 +3378,7 @@ public class Cooja extends Observable {
}
/* Verify extension directories */
boolean projectsOk = verifyProjects(root.getChildren(), !quick);
boolean projectsOk = verifyProjects(root.getChildren());
/* GENERATE UNIQUE MOTE TYPE IDENTIFIERS */
root.detach();
@ -3428,7 +3428,8 @@ public class Cooja extends Observable {
Collection<Element> config = ((Element) element).getChildren();
newSim = new Simulation(this);
System.gc();
boolean createdOK = newSim.setConfigXML(config, !quick, manualRandomSeed);
boolean createdOK = newSim.setConfigXML(config, isVisualized(), quick, manualRandomSeed);
if (!createdOK) {
logger.info("Simulation not loaded");
return null;
@ -3437,7 +3438,7 @@ public class Cooja extends Observable {
}
// Restart plugins from config
setPluginsConfigXML(root.getChildren(), newSim, !quick);
setPluginsConfigXML(root.getChildren(), newSim, isVisualized(), quick);
} catch (JDOMException e) {
throw (SimulationCreationException) new SimulationCreationException(
@ -3599,7 +3600,7 @@ public class Cooja extends Observable {
return config;
}
public boolean verifyProjects(Collection<Element> configXML, boolean visAvailable) {
public boolean verifyProjects(Collection<Element> configXML) {
boolean allOk = true;
/* Match current extensions against extensions in simulation config */
@ -3641,8 +3642,8 @@ public class Cooja extends Observable {
* @return True if all plugins started, false otherwise
*/
public boolean setPluginsConfigXML(Collection<Element> configXML,
Simulation simulation, boolean visAvailable) {
Simulation simulation, boolean visAvailable, boolean quick) {
for (final Element pluginElement : configXML.toArray(new Element[0])) {
if (pluginElement.getName().equals("plugin")) {

View file

@ -35,8 +35,9 @@ import java.util.Vector;
import org.contikios.cooja.MoteType.MoteTypeCreationException;
import org.contikios.cooja.contikimote.ContikiMoteType;
import org.contikios.cooja.dialogs.MessageContainer;
import org.contikios.cooja.dialogs.MessageList;
import org.contikios.cooja.dialogs.MessageListUI;
/**
* The purpose of corecomm's is communicating with a compiled Contiki system
@ -204,9 +205,10 @@ public abstract class CoreComm {
*/
public static void compileSourceFile(String className)
throws MoteTypeCreationException {
MessageListUI compilationOutput = new MessageListUI();
/* Try to create a message list with support for GUI - will give not UI if headless */
MessageList compilationOutput = MessageContainer.createMessageList(true);
OutputStream compilationStandardStream = compilationOutput
.getInputStream(MessageListUI.NORMAL);
.getInputStream(MessageList.NORMAL);
OutputStream compilationErrorStream = compilationOutput
.getInputStream(MessageList.ERROR);

View file

@ -71,6 +71,7 @@ public class Simulation extends Observable implements Runnable {
private long speedLimitLastSimtime;
private long speedLimitLastRealtime;
private long lastStartTime;
private long currentSimulationTime = 0;
private String title = null;
@ -248,7 +249,7 @@ public class Simulation extends Observable implements Runnable {
}
public void run() {
long lastStartTime = System.currentTimeMillis();
lastStartTime = System.currentTimeMillis();
logger.info("Simulation main loop started, system time: " + lastStartTime);
isRunning = true;
speedLimitLastRealtime = System.currentTimeMillis();
@ -543,6 +544,17 @@ public class Simulation extends Observable implements Runnable {
return config;
}
/* indicator to components setting up that they need to respect the fast setup mode */
private boolean quick = false;
public boolean isQuickSetup() {
return quick;
}
public void setQuickSetup(boolean q) {
quick = q;
}
/**
* Sets the current simulation config depending on the given configuration.
*
@ -553,8 +565,9 @@ public class Simulation extends Observable implements Runnable {
* @throws Exception If configuration could not be loaded
*/
public boolean setConfigXML(Collection<Element> configXML,
boolean visAvailable, Long manualRandomSeed) throws Exception {
boolean visAvailable, boolean quick, Long manualRandomSeed) throws Exception {
setQuickSetup(quick);
// Parse elements
for (Element element : configXML) {
@ -622,7 +635,7 @@ public class Simulation extends Observable implements Runnable {
// Show configure simulation dialog
boolean createdOK = false;
if (visAvailable) {
if (visAvailable && !quick) {
createdOK = CreateSimDialog.showDialog(Cooja.getTopParentContainer(), this);
} else {
createdOK = true;
@ -656,7 +669,7 @@ public class Simulation extends Observable implements Runnable {
}
/* Try to recreate simulation using a different mote type */
if (visAvailable) {
if (visAvailable && !quick) {
String[] availableMoteTypes = getCooja().getProjectConfig().getStringArrayValue("org.contikios.cooja.Cooja.MOTETYPES");
String newClass = (String) JOptionPane.showInputDialog(
Cooja.getTopParentContainer(),
@ -1075,6 +1088,16 @@ public class Simulation extends Observable implements Runnable {
return currentSimulationTime / MILLISECOND;
}
/**
* Return the actual time value corresponding to an argument which
* is a simulation time value in microseconds.
*
* @return Actual time (microseconds)
*/
public long convertSimTimeToActualTime(long simTime) {
return simTime + lastStartTime * 1000;
}
/**
* Changes radio medium of this simulation to the given.
*

View file

@ -66,7 +66,7 @@ import org.contikios.cooja.mote.memory.SectionMoteMemory;
import org.contikios.cooja.Simulation;
import org.contikios.cooja.dialogs.CompileContiki;
import org.contikios.cooja.dialogs.ContikiMoteCompileDialog;
import org.contikios.cooja.dialogs.MessageListUI;
import org.contikios.cooja.dialogs.MessageList;
import org.contikios.cooja.dialogs.MessageContainer;
import org.contikios.cooja.mote.memory.ArrayMemory;
import org.contikios.cooja.mote.memory.MemoryInterface;
@ -317,7 +317,7 @@ public class ContikiMoteType implements MoteType {
if (getCompileCommands() == null) {
throw new MoteTypeCreationException("No compile commands specified");
}
final MessageListUI compilationOutput = new MessageListUI();
final MessageList compilationOutput = MessageContainer.createMessageList(visAvailable);
String[] arr = getCompileCommands().split("\n");
for (String cmd : arr) {
if (cmd.trim().isEmpty()) {
@ -401,7 +401,7 @@ public class ContikiMoteType implements MoteType {
}
// Allocate core communicator class
logger.info("Creating core communicator between Java class " + javaClassName + " and Contiki library '" + getContikiFirmwareFile().getPath() + "");
logger.info("Creating core communicator between Java class " + javaClassName + " and Contiki library '" + getContikiFirmwareFile().getPath() + "'");
myCoreComm = CoreComm.createCoreComm(this.javaClassName, getContikiFirmwareFile());
/* Parse addresses using map file

View file

@ -52,8 +52,11 @@ import org.contikios.cooja.mote.memory.VarMemory;
* Contiki variables:
* <ul>
* <li>clock_time_t simCurrentTime
* <li>clock_time_t simNextExpirationTime
* <li>int simProcessRunValue
* <li>rtimer_clock_t simRtimerCurrentTicks
* <li>clock_time_t simEtimerNextExpirationTime
* <li>rtimer_clock_t simEtimerNextExpirationTime
* <li>int simEtimerProcessRunValue
* <li>int simRtimerProcessRunValue
* <li>int simEtimerPending
* </ul>
*
@ -125,16 +128,24 @@ public class ContikiClock extends Clock implements ContikiMoteInterface, PolledB
public void doActionsBeforeTick() {
/* Update time */
setTime(mote.getSimulation().getSimulationTime() + timeDrift);
long currentSimulationTime = simulation.getSimulationTime();
setTime(currentSimulationTime + timeDrift);
moteMem.setInt64ValueOf("simRtimerCurrentTicks", currentSimulationTime);
}
public void doActionsAfterTick() {
long currentSimulationTime = mote.getSimulation().getSimulationTime();
/* Always schedule for Rtimer if anything pending */
if (moteMem.getIntValueOf("simRtimerPending") != 0) {
mote.scheduleNextWakeup(moteMem.getInt64ValueOf("simRtimerNextExpirationTime"));
}
/* Request next tick for remaining events / timers */
int processRunValue = moteMem.getIntValueOf("simProcessRunValue");
if (processRunValue != 0) {
/* Handle next Contiki event in one millisecond */
mote.scheduleNextWakeup(simulation.getSimulationTime() + Simulation.MILLISECOND);
mote.scheduleNextWakeup(currentSimulationTime + Simulation.MILLISECOND);
return;
}
@ -144,15 +155,20 @@ public class ContikiClock extends Clock implements ContikiMoteInterface, PolledB
return;
}
/* Request tick next wakeup time */
int nextExpirationTime = moteMem.getIntValueOf("simNextExpirationTime");
if (nextExpirationTime <= 0) {
/*logger.warn("Event timer already expired, but has been delayed: " + nextExpirationTime);*/
mote.scheduleNextWakeup(simulation.getSimulationTime() + Simulation.MILLISECOND);
return;
/* Request tick next wakeup time for Etimer */
long etimerNextExpirationTime = (long)moteMem.getInt32ValueOf("simEtimerNextExpirationTime") * Simulation.MILLISECOND;
long etimerTimeToNextExpiration = etimerNextExpirationTime - moteTime;
if (etimerTimeToNextExpiration <= 0) {
/* logger.warn(mote.getID() + ": Event timer already expired, but has been delayed: " + etimerTimeToNextExpiration); */
/* Wake up in one millisecond to handle a missed Etimer task
* which may be blocked by busy waiting such as one in
* radio_send(). Scheduling it in a shorter time than one
* millisecond, e.g., one microsecond, seems to be worthless and
* it would cause unnecessary CPU usage. */
mote.scheduleNextWakeup(currentSimulationTime + Simulation.MILLISECOND);
} else {
mote.scheduleNextWakeup(currentSimulationTime + etimerTimeToNextExpiration);
}
mote.scheduleNextWakeup(simulation.getSimulationTime() + Simulation.MILLISECOND*nextExpirationTime);
}

View file

@ -62,6 +62,7 @@ import org.contikios.cooja.util.CCITT_CRC;
* <p>
* <li>int simInSize (size of received data packet)
* <li>byte[] simInDataBuffer (data of received data packet)
* <li>int64_t simLastPacketTimestamp (timestamp of the last received data packet)
* <p>
* <li>int simOutSize (size of transmitted data packet)
* <li>byte[] simOutDataBuffer (data of transmitted data packet)
@ -190,6 +191,8 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface, PolledA
lastEventTime = mote.getSimulation().getSimulationTime();
lastEvent = RadioEvent.RECEPTION_STARTED;
myMoteMemory.setInt64ValueOf("simLastPacketTimestamp", lastEventTime);
this.setChanged();
this.notifyObservers();
}

View file

@ -127,7 +127,7 @@ public class CompileContiki {
/* TODO Fix me */
final MessageList messageDialog;
if (compilationOutput == null) {
messageDialog = new MessageListUI();
messageDialog = MessageContainer.createMessageList(true);
} else {
messageDialog = compilationOutput;
}
@ -138,8 +138,8 @@ public class CompileContiki {
cmd += c + " ";
}
logger.info("> " + cmd);
messageDialog.addMessage("", MessageListUI.NORMAL);
messageDialog.addMessage("> " + cmd, MessageListUI.NORMAL);
messageDialog.addMessage("", MessageList.NORMAL);
messageDialog.addMessage("> " + cmd, MessageList.NORMAL);
}
final Process compileProcess;
@ -170,7 +170,7 @@ public class CompileContiki {
String readLine;
while ((readLine = processNormal.readLine()) != null) {
if (messageDialog != null) {
messageDialog.addMessage(readLine, MessageListUI.NORMAL);
messageDialog.addMessage(readLine, MessageList.NORMAL);
}
}
} catch (IOException e) {
@ -203,7 +203,7 @@ public class CompileContiki {
compileProcess.waitFor();
} catch (Exception e) {
messageDialog.addMessage(e.getMessage(), MessageList.ERROR);
syncException.setCompilationOutput(new MessageListUI());
syncException.setCompilationOutput(MessageContainer.createMessageList(true));
syncException.fillInStackTrace();
return;
}
@ -214,7 +214,7 @@ public class CompileContiki {
if (onFailure != null) {
onFailure.actionPerformed(null);
}
syncException.setCompilationOutput(new MessageListUI());
syncException.setCompilationOutput(MessageContainer.createMessageList(true));
syncException.fillInStackTrace();
return;
}
@ -232,13 +232,13 @@ public class CompileContiki {
if (onFailure != null) {
onFailure.actionPerformed(null);
}
syncException.setCompilationOutput(new MessageListUI());
syncException.setCompilationOutput(MessageContainer.createMessageList(true));
syncException.fillInStackTrace();
return;
}
messageDialog.addMessage("", MessageListUI.NORMAL);
messageDialog.addMessage("Compilation succeded", MessageListUI.NORMAL);
messageDialog.addMessage("", MessageList.NORMAL);
messageDialog.addMessage("Compilation succeded", MessageList.NORMAL);
if (onSuccess != null) {
onSuccess.actionPerformed(null);
}

View file

@ -1,4 +1,7 @@
package org.contikios.cooja.dialogs;
import java.awt.GraphicsEnvironment;
import org.contikios.cooja.Cooja;
public class MessageContainer {
@ -14,4 +17,15 @@ public class MessageContainer {
public String toString() {
return message;
}
/* This will select UI based or not UI based depending on withUI in combination with
* headless info.
*/
public static MessageList createMessageList(boolean withUI) {
if (withUI && !GraphicsEnvironment.isHeadless() && Cooja.isVisualized()) {
return new MessageListUI();
} else {
return new MessageListText();
}
}
}

View file

@ -1,5 +1,7 @@
package org.contikios.cooja.dialogs;
import java.io.OutputStream;
public interface MessageList {
public static final int NORMAL = 0;
@ -14,4 +16,6 @@ public interface MessageList {
public void addMessage(String string);
public OutputStream getInputStream(int type);
}

View file

@ -1,7 +1,12 @@
package org.contikios.cooja.dialogs;
import java.io.OutputStream;
public class MessageListText implements MessageList {
public MessageListText() {
}
@Override
public void addMessage(String string, int type) {
System.out.println("Message:" + string);
@ -24,4 +29,12 @@ public class MessageListText implements MessageList {
addMessage(string, MessageList.NORMAL);
}
@Override
public OutputStream getInputStream(int type) {
// TODO Auto-generated method stub
return System.out;
}
}

View file

@ -33,6 +33,7 @@ package org.contikios.cooja.dialogs;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GraphicsEnvironment;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
@ -81,6 +82,9 @@ public class MessageListUI extends JList implements MessageList {
private int max = -1;
public MessageListUI() {
if (GraphicsEnvironment.isHeadless()) {
throw new RuntimeException("Can not use UI version of message list in Headless mode");
}
super.setModel(new MessageModel());
setCellRenderer(new MessageRenderer());
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

View file

@ -263,7 +263,7 @@ public class VarMemory extends Memory {
* @param varName Variable name
* @param value 16 bit integer value to write
*/
public void setInt16ValueOf(String varName, byte value)
public void setInt16ValueOf(String varName, short value)
throws UnknownVariableException {
setInt16ValueOf(getVariable(varName).addr, value);
}
@ -274,7 +274,7 @@ public class VarMemory extends Memory {
* @param varName Variable name
* @param value 32 bit integer value to write
*/
public void setInt32ValueOf(String varName, byte value)
public void setInt32ValueOf(String varName, int value)
throws UnknownVariableException {
setInt32ValueOf(getVariable(varName).addr, value);
}
@ -285,7 +285,7 @@ public class VarMemory extends Memory {
* @param varName Variable name
* @param value 64 bit integer value to write
*/
public void setInt64ValueOf(String varName, byte value)
public void setInt64ValueOf(String varName, long value)
throws UnknownVariableException {
setInt64ValueOf(getVariable(varName).addr, value);
}

View file

@ -694,8 +694,8 @@ public class RadioLogger extends VisPlugin {
StringBuilder verbose = new StringBuilder();
/* default analyzer */
PacketAnalyzer.Packet packet = new PacketAnalyzer.Packet(data, PacketAnalyzer.MAC_LEVEL);
PacketAnalyzer.Packet packet = new PacketAnalyzer.Packet(data, PacketAnalyzer.MAC_LEVEL,
simulation.convertSimTimeToActualTime(conn.startTime));
if (analyzePacket(packet, brief, verbose)) {
if (packet.hasMoreData()) {
byte[] payload = packet.getPayload();

View file

@ -69,7 +69,7 @@ public class IEEE802154Analyzer extends PacketAnalyzer {
if (pcapExporter != null) {
try {
pcapExporter.exportPacketData(packet.getPayload());
pcapExporter.exportPacketData(packet.getPayload(), packet.getTimestamp());
} catch (IOException e) {
logger.error("Could not export PCap data", e);
}

View file

@ -18,6 +18,7 @@ public abstract class PacketAnalyzer {
int level;
/* size = length - consumed bytes at tail */
int size;
long ts; /* in microseconds */
/* L2 addresseses */
byte[] llsender;
@ -25,10 +26,11 @@ public abstract class PacketAnalyzer {
byte lastDispatch = 0;
public Packet(byte[] data, int level) {
public Packet(byte[] data, int level, long ts) {
this.level = level;
this.data = data.clone();
this.size = data.length;
this.ts = ts;
}
public void consumeBytesStart(int bytes) {
@ -79,6 +81,10 @@ public abstract class PacketAnalyzer {
public byte[] getLLReceiver() {
return llreceiver;
}
public long getTimestamp() {
return ts;
}
};
public abstract boolean matchPacket(Packet packet);

View file

@ -41,15 +41,15 @@ public class PcapExporter {
out = null;
}
public void exportPacketData(byte[] data) throws IOException {
public void exportPacketData(byte[] data, long ts) throws IOException {
if (out == null) {
/* pcap file never set, open default */
openPcap(null);
}
try {
/* pcap packet header */
out.writeInt((int) (System.currentTimeMillis() / 1000));
out.writeInt((int) ((System.currentTimeMillis() % 1000) * 1000));
out.writeInt((int) (ts / 1000000));
out.writeInt((int) (ts % 1000000));
out.writeInt(data.length);
out.writeInt(data.length);
/* and the data */

1
tools/sensniff Submodule

@ -0,0 +1 @@
Subproject commit 0d57c1129b601d29a58bffe6e34803af5e1701af

View file

@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <signal.h>
#define BAUDRATE B115200
#define BAUDRATE_S "115200"
@ -82,9 +83,17 @@ print_hex_line(char *prefix, unsigned char *outbuf, int index)
}
}
static void
intHandler(int sig)
{
exit(0);
}
int
main(int argc, char **argv)
{
signal(SIGINT, intHandler);
struct termios options;
fd_set mask, smask;
int fd;
@ -208,6 +217,8 @@ main(int argc, char **argv)
options.c_cflag |= CS8;
/* Raw input */
options.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP
| INLCR | IGNCR | ICRNL | IXON);
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
/* Raw output */
options.c_oflag &= ~OPOST;
@ -279,6 +290,11 @@ main(int argc, char **argv)
perror("could not read");
exit(-1);
}
if(n == 0) {
errno = EBADF;
perror("serial device disconnected");
exit(-1);
}
for(i = 0; i < n; i++) {
switch(mode) {

View file

@ -59,6 +59,8 @@ if( $Opt{board} eq "z1" ) {
$Opt{board} = "Zolertia RE-Mote platform";
} elsif( $Opt{board} eq "firefly" ) {
$Opt{board} = "Zolertia Firefly platform";
} elsif( $Opt{board} eq "orion" ) {
$Opt{board} = "Zolertia Orion Ethernet router";
}
my @devs = $Opt{method} eq "procfs" ? scan_procfs() : scan_sysfs();