mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-22 10:30:13 +00:00
Deferred listening on memory until after mote id has been set
This commit is contained in:
parent
7110075108
commit
f891774c1f
@ -30,9 +30,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.mspmote.interfaces;
|
package se.sics.cooja.mspmote.interfaces;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Observable;
|
import java.util.Observable;
|
||||||
import java.util.Observer;
|
import java.util.Observer;
|
||||||
|
|
||||||
@ -40,7 +37,6 @@ import javax.swing.JLabel;
|
|||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.jdom.Element;
|
|
||||||
|
|
||||||
import se.sics.cooja.Mote;
|
import se.sics.cooja.Mote;
|
||||||
import se.sics.cooja.MoteTimeEvent;
|
import se.sics.cooja.MoteTimeEvent;
|
||||||
@ -76,41 +72,6 @@ public class MspMoteID extends MoteID {
|
|||||||
public MspMoteID(Mote m) {
|
public MspMoteID(Mote m) {
|
||||||
this.mote = (MspMote) m;
|
this.mote = (MspMote) m;
|
||||||
this.moteMem = (MspMoteMemory) mote.getMemory();
|
this.moteMem = (MspMoteMemory) mote.getMemory();
|
||||||
|
|
||||||
final MoteTimeEvent writeIDEvent = new MoteTimeEvent(mote, 0) {
|
|
||||||
public void execute(long t) {
|
|
||||||
setMoteID(moteID);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
cpuMonitor = new CPUMonitor() {
|
|
||||||
public void cpuAction(int type, int adr, int data) {
|
|
||||||
if (type != MEMORY_WRITE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (data == moteID) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Simulation s = mote.getSimulation();
|
|
||||||
if (writeIDEvent.isScheduled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
s.scheduleEvent(writeIDEvent, s.getSimulationTime());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (moteMem.variableExists("node_id")) {
|
|
||||||
this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("node_id"), cpuMonitor);
|
|
||||||
}
|
|
||||||
if (moteMem.variableExists("TOS_NODE_ID")) {
|
|
||||||
this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("TOS_NODE_ID"), cpuMonitor);
|
|
||||||
}
|
|
||||||
if (moteMem.variableExists("ActiveMessageAddressC__addr")) {
|
|
||||||
this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC__addr"), cpuMonitor);
|
|
||||||
}
|
|
||||||
if (moteMem.variableExists("ActiveMessageAddressC$addr")) {
|
|
||||||
this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC$addr"), cpuMonitor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMoteID() {
|
public int getMoteID() {
|
||||||
@ -149,6 +110,42 @@ public class MspMoteID extends MoteID {
|
|||||||
if (moteMem.variableExists("ActiveMessageAddressC$addr")) {
|
if (moteMem.variableExists("ActiveMessageAddressC$addr")) {
|
||||||
moteMem.setIntValueOf("ActiveMessageAddressC$addr", newID);
|
moteMem.setIntValueOf("ActiveMessageAddressC$addr", newID);
|
||||||
}
|
}
|
||||||
|
if (cpuMonitor == null) {
|
||||||
|
final MoteTimeEvent writeIDEvent = new MoteTimeEvent(mote, 0) {
|
||||||
|
public void execute(long t) {
|
||||||
|
setMoteID(moteID);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
cpuMonitor = new CPUMonitor() {
|
||||||
|
public void cpuAction(int type, int address, int data) {
|
||||||
|
if (type != MEMORY_WRITE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (data == moteID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (writeIDEvent.isScheduled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Simulation s = mote.getSimulation();
|
||||||
|
s.scheduleEvent(writeIDEvent, s.getSimulationTime());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (moteMem.variableExists("node_id")) {
|
||||||
|
this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("node_id"), cpuMonitor);
|
||||||
|
}
|
||||||
|
if (moteMem.variableExists("TOS_NODE_ID")) {
|
||||||
|
this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("TOS_NODE_ID"), cpuMonitor);
|
||||||
|
}
|
||||||
|
if (moteMem.variableExists("ActiveMessageAddressC__addr")) {
|
||||||
|
this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC__addr"), cpuMonitor);
|
||||||
|
}
|
||||||
|
if (moteMem.variableExists("ActiveMessageAddressC$addr")) {
|
||||||
|
this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC$addr"), cpuMonitor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
notifyObservers();
|
notifyObservers();
|
||||||
}
|
}
|
||||||
@ -185,17 +182,20 @@ public class MspMoteID extends MoteID {
|
|||||||
|
|
||||||
public void removed() {
|
public void removed() {
|
||||||
super.removed();
|
super.removed();
|
||||||
if (moteMem.variableExists("node_id")) {
|
if (cpuMonitor != null) {
|
||||||
this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("node_id"), cpuMonitor);
|
if (moteMem.variableExists("node_id")) {
|
||||||
}
|
this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("node_id"), cpuMonitor);
|
||||||
if (moteMem.variableExists("TOS_NODE_ID")) {
|
}
|
||||||
this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("TOS_NODE_ID"), cpuMonitor);
|
if (moteMem.variableExists("TOS_NODE_ID")) {
|
||||||
}
|
this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("TOS_NODE_ID"), cpuMonitor);
|
||||||
if (moteMem.variableExists("ActiveMessageAddressC__addr")) {
|
}
|
||||||
this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC__addr"), cpuMonitor);
|
if (moteMem.variableExists("ActiveMessageAddressC__addr")) {
|
||||||
}
|
this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC__addr"), cpuMonitor);
|
||||||
if (moteMem.variableExists("ActiveMessageAddressC$addr")) {
|
}
|
||||||
this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC$addr"), cpuMonitor);
|
if (moteMem.variableExists("ActiveMessageAddressC$addr")) {
|
||||||
|
this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC$addr"), cpuMonitor);
|
||||||
|
}
|
||||||
|
cpuMonitor = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user