[cooja] getMemory() now returns MemoryInterface
Including code adaptions based on new memory methods to keep code compilable
This commit is contained in:
parent
19d07beb16
commit
9dd29d56c9
@ -43,6 +43,8 @@ import org.contikios.cooja.MoteInterfaceHandler;
|
|||||||
import org.contikios.cooja.MoteMemory;
|
import org.contikios.cooja.MoteMemory;
|
||||||
import org.contikios.cooja.MoteType;
|
import org.contikios.cooja.MoteType;
|
||||||
import org.contikios.cooja.Simulation;
|
import org.contikios.cooja.Simulation;
|
||||||
|
import org.contikios.cooja.mote.memory.MemoryInterface;
|
||||||
|
import org.contikios.cooja.mote.memory.MemoryLayout;
|
||||||
import org.contikios.cooja.motes.AbstractEmulatedMote;
|
import org.contikios.cooja.motes.AbstractEmulatedMote;
|
||||||
import avrora.arch.avr.AVRProperties;
|
import avrora.arch.avr.AVRProperties;
|
||||||
import avrora.core.LoadableProgram;
|
import avrora.core.LoadableProgram;
|
||||||
@ -54,7 +56,6 @@ import avrora.sim.mcu.EEPROM;
|
|||||||
import avrora.sim.platform.MicaZ;
|
import avrora.sim.platform.MicaZ;
|
||||||
import avrora.sim.platform.PlatformFactory;
|
import avrora.sim.platform.PlatformFactory;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
import org.contikios.cooja.mote.memory.MemoryLayout;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Joakim Eriksson, Fredrik Osterlind
|
* @author Joakim Eriksson, Fredrik Osterlind
|
||||||
@ -267,7 +268,8 @@ public class MicaZMote extends AbstractEmulatedMote implements Mote {
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MoteMemory getMemory() {
|
@Override
|
||||||
|
public MemoryInterface getMemory() {
|
||||||
return myMemory;
|
return myMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ import org.contikios.cooja.Simulation;
|
|||||||
import org.contikios.cooja.Watchpoint;
|
import org.contikios.cooja.Watchpoint;
|
||||||
import org.contikios.cooja.WatchpointMote;
|
import org.contikios.cooja.WatchpointMote;
|
||||||
import org.contikios.cooja.interfaces.IPAddress;
|
import org.contikios.cooja.interfaces.IPAddress;
|
||||||
|
import org.contikios.cooja.mote.memory.MemoryInterface;
|
||||||
import org.contikios.cooja.mote.memory.MemoryLayout;
|
import org.contikios.cooja.mote.memory.MemoryLayout;
|
||||||
import org.contikios.cooja.motes.AbstractEmulatedMote;
|
import org.contikios.cooja.motes.AbstractEmulatedMote;
|
||||||
import org.contikios.cooja.mspmote.interfaces.Msp802154Radio;
|
import org.contikios.cooja.mspmote.interfaces.Msp802154Radio;
|
||||||
@ -188,7 +189,8 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
|
|||||||
myCpu = cpu;
|
myCpu = cpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MoteMemory getMemory() {
|
@Override
|
||||||
|
public MemoryInterface getMemory() {
|
||||||
return myMemory;
|
return myMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
package org.contikios.cooja;
|
package org.contikios.cooja;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import org.contikios.cooja.mote.memory.MemoryInterface;
|
||||||
|
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
|
|
||||||
@ -63,7 +64,7 @@ public interface Mote {
|
|||||||
* @see #setMemory(MoteMemory)
|
* @see #setMemory(MoteMemory)
|
||||||
* @return Mote memory
|
* @return Mote memory
|
||||||
*/
|
*/
|
||||||
public MoteMemory getMemory();
|
public MemoryInterface getMemory();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns mote type.
|
* Returns mote type.
|
||||||
|
@ -42,6 +42,7 @@ import org.contikios.cooja.MoteMemory;
|
|||||||
import org.contikios.cooja.MoteType;
|
import org.contikios.cooja.MoteType;
|
||||||
import org.contikios.cooja.SectionMoteMemory;
|
import org.contikios.cooja.SectionMoteMemory;
|
||||||
import org.contikios.cooja.Simulation;
|
import org.contikios.cooja.Simulation;
|
||||||
|
import org.contikios.cooja.mote.memory.MemoryInterface;
|
||||||
import org.contikios.cooja.motes.AbstractWakeupMote;
|
import org.contikios.cooja.motes.AbstractWakeupMote;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,7 +99,7 @@ public class ContikiMote extends AbstractWakeupMote implements Mote {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MoteMemory getMemory() {
|
public MemoryInterface getMemory() {
|
||||||
return myMemory;
|
return myMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,9 +42,9 @@ import org.jdom.Element;
|
|||||||
import org.contikios.cooja.ClassDescription;
|
import org.contikios.cooja.ClassDescription;
|
||||||
import org.contikios.cooja.Mote;
|
import org.contikios.cooja.Mote;
|
||||||
import org.contikios.cooja.MoteInterface;
|
import org.contikios.cooja.MoteInterface;
|
||||||
import org.contikios.cooja.MoteMemory;
|
import org.contikios.cooja.mote.memory.MemoryInterface;
|
||||||
import org.contikios.cooja.MoteMemory.MemoryEventType;
|
import org.contikios.cooja.mote.memory.MemoryInterface.SegmentMonitor;
|
||||||
import org.contikios.cooja.MoteMemory.MemoryMonitor;
|
import org.contikios.cooja.mote.memory.VarMemory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read-only interface to IPv4 or IPv6 address.
|
* Read-only interface to IPv4 or IPv6 address.
|
||||||
@ -54,21 +54,22 @@ import org.contikios.cooja.MoteMemory.MemoryMonitor;
|
|||||||
@ClassDescription("IP Address")
|
@ClassDescription("IP Address")
|
||||||
public class IPAddress extends MoteInterface {
|
public class IPAddress extends MoteInterface {
|
||||||
private static Logger logger = Logger.getLogger(IPAddress.class);
|
private static Logger logger = Logger.getLogger(IPAddress.class);
|
||||||
private final MoteMemory moteMem;
|
private final VarMemory moteMem;
|
||||||
|
|
||||||
private static final int IPv6_MAX_ADDRESSES = 4;
|
private static final int IPv6_MAX_ADDRESSES = 4;
|
||||||
private boolean ipv6IsGlobal = false;
|
private boolean ipv6IsGlobal = false;
|
||||||
private int ipv6AddressIndex = -1;
|
private int ipv6AddressIndex = -1;
|
||||||
|
|
||||||
private static final int MONITORED_SIZE = 150;
|
private static final int MONITORED_SIZE = 150;
|
||||||
private MemoryMonitor memMonitor;
|
private SegmentMonitor memMonitor;
|
||||||
|
|
||||||
public IPAddress(final Mote mote) {
|
public IPAddress(final Mote mote) {
|
||||||
moteMem = mote.getMemory();
|
moteMem = new VarMemory(mote.getMemory());
|
||||||
|
|
||||||
memMonitor = new MemoryMonitor() {
|
memMonitor = new MemoryInterface.SegmentMonitor() {
|
||||||
public void memoryChanged(MoteMemory memory, MemoryEventType type, int address) {
|
@Override
|
||||||
if (type != MemoryEventType.WRITE) {
|
public void memoryChanged(MemoryInterface memory, SegmentMonitor.EventType type, long address) {
|
||||||
|
if (type != SegmentMonitor.EventType.WRITE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setChanged();
|
setChanged();
|
||||||
@ -76,11 +77,11 @@ public class IPAddress extends MoteInterface {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (isVersion4()) {
|
if (isVersion4()) {
|
||||||
moteMem.addMemoryMonitor(moteMem.getVariableAddress("uip_hostaddr"), 4, memMonitor);
|
moteMem.addVarMonitor(SegmentMonitor.EventType.WRITE, "uip_hostaddr", memMonitor);
|
||||||
} else if (isVersion6()) {
|
} else if (isVersion6()) {
|
||||||
moteMem.addMemoryMonitor(moteMem.getVariableAddress("uip_ds6_netif_addr_list_offset"), 1, memMonitor);
|
moteMem.addVarMonitor(SegmentMonitor.EventType.WRITE, "uip_ds6_netif_addr_list_offset", memMonitor);
|
||||||
moteMem.addMemoryMonitor(moteMem.getVariableAddress("uip_ds6_addr_size"), 1, memMonitor);
|
moteMem.addVarMonitor(SegmentMonitor.EventType.WRITE, "uip_ds6_addr_size", memMonitor);
|
||||||
moteMem.addMemoryMonitor(moteMem.getVariableAddress("uip_ds6_if"), MONITORED_SIZE, memMonitor);
|
moteMem.addVarMonitor(SegmentMonitor.EventType.WRITE, "uip_ds6_if", memMonitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,11 +206,11 @@ public class IPAddress extends MoteInterface {
|
|||||||
super.removed();
|
super.removed();
|
||||||
if (memMonitor != null) {
|
if (memMonitor != null) {
|
||||||
if (isVersion4()) {
|
if (isVersion4()) {
|
||||||
moteMem.removeMemoryMonitor(moteMem.getVariableAddress("rimeaddr_node_addr"), 4, memMonitor);
|
moteMem.removeVarMonitor("rimeaddr_node_addr", memMonitor);
|
||||||
} else if (isVersion6()) {
|
} else if (isVersion6()) {
|
||||||
moteMem.removeMemoryMonitor(moteMem.getVariableAddress("uip_ds6_netif_addr_list_offset"), 1, memMonitor);
|
moteMem.removeVarMonitor("uip_ds6_netif_addr_list_offset", memMonitor);
|
||||||
moteMem.removeMemoryMonitor(moteMem.getVariableAddress("uip_ds6_addr_size"), 1, memMonitor);
|
moteMem.removeVarMonitor("uip_ds6_addr_size", memMonitor);
|
||||||
moteMem.removeMemoryMonitor(moteMem.getVariableAddress("uip_ds6_if"), MONITORED_SIZE, memMonitor);
|
moteMem.removeVarMonitor("uip_ds6_if", memMonitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,9 +43,9 @@ import org.jdom.Element;
|
|||||||
import org.contikios.cooja.ClassDescription;
|
import org.contikios.cooja.ClassDescription;
|
||||||
import org.contikios.cooja.Mote;
|
import org.contikios.cooja.Mote;
|
||||||
import org.contikios.cooja.MoteInterface;
|
import org.contikios.cooja.MoteInterface;
|
||||||
import org.contikios.cooja.MoteMemory;
|
import org.contikios.cooja.mote.memory.MemoryInterface;
|
||||||
import org.contikios.cooja.MoteMemory.MemoryEventType;
|
import org.contikios.cooja.mote.memory.MemoryInterface.SegmentMonitor;
|
||||||
import org.contikios.cooja.MoteMemory.MemoryMonitor;
|
import org.contikios.cooja.mote.memory.VarMemory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read-only interface to Rime address read from Contiki variable: linkaddr_node_addr.
|
* Read-only interface to Rime address read from Contiki variable: linkaddr_node_addr.
|
||||||
@ -57,18 +57,19 @@ import org.contikios.cooja.MoteMemory.MemoryMonitor;
|
|||||||
@ClassDescription("Rime address")
|
@ClassDescription("Rime address")
|
||||||
public class RimeAddress extends MoteInterface {
|
public class RimeAddress extends MoteInterface {
|
||||||
private static Logger logger = Logger.getLogger(RimeAddress.class);
|
private static Logger logger = Logger.getLogger(RimeAddress.class);
|
||||||
private MoteMemory moteMem;
|
private VarMemory moteMem;
|
||||||
|
|
||||||
public static final int RIME_ADDR_LENGTH = 2;
|
public static final int RIME_ADDR_LENGTH = 2;
|
||||||
|
|
||||||
private MemoryMonitor memMonitor = null;
|
private SegmentMonitor memMonitor = null;
|
||||||
|
|
||||||
public RimeAddress(final Mote mote) {
|
public RimeAddress(final Mote mote) {
|
||||||
moteMem = mote.getMemory();
|
moteMem = new VarMemory(mote.getMemory());
|
||||||
if (hasRimeAddress()) {
|
if (hasRimeAddress()) {
|
||||||
memMonitor = new MemoryMonitor() {
|
memMonitor = new SegmentMonitor() {
|
||||||
public void memoryChanged(MoteMemory memory, MemoryEventType type, int address) {
|
@Override
|
||||||
if (type != MemoryEventType.WRITE) {
|
public void memoryChanged(MemoryInterface memory, SegmentMonitor.EventType type, long address) {
|
||||||
|
if (type != SegmentMonitor.EventType.WRITE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setChanged();
|
setChanged();
|
||||||
@ -76,7 +77,7 @@ public class RimeAddress extends MoteInterface {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
/* TODO XXX Timeout? */
|
/* TODO XXX Timeout? */
|
||||||
moteMem.addMemoryMonitor(moteMem.getVariableAddress("linkaddr_node_addr"), RIME_ADDR_LENGTH, memMonitor);
|
moteMem.addVarMonitor(SegmentMonitor.EventType.WRITE, "linkaddr_node_addr", memMonitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +132,7 @@ public class RimeAddress extends MoteInterface {
|
|||||||
public void removed() {
|
public void removed() {
|
||||||
super.removed();
|
super.removed();
|
||||||
if (memMonitor != null) {
|
if (memMonitor != null) {
|
||||||
moteMem.removeMemoryMonitor(moteMem.getVariableAddress("linkaddr_node_addr"), RIME_ADDR_LENGTH, memMonitor);
|
moteMem.removeVarMonitor("linkaddr_node_addr", memMonitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ import org.contikios.cooja.Simulation;
|
|||||||
import org.contikios.cooja.interfaces.ApplicationRadio;
|
import org.contikios.cooja.interfaces.ApplicationRadio;
|
||||||
import org.contikios.cooja.interfaces.ApplicationSerialPort;
|
import org.contikios.cooja.interfaces.ApplicationSerialPort;
|
||||||
import org.contikios.cooja.interfaces.Radio;
|
import org.contikios.cooja.interfaces.Radio;
|
||||||
|
import org.contikios.cooja.mote.memory.MemoryInterface;
|
||||||
import org.contikios.cooja.mote.memory.MemoryLayout;
|
import org.contikios.cooja.mote.memory.MemoryLayout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,7 +112,7 @@ public abstract class AbstractApplicationMote extends AbstractWakeupMote impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MoteMemory getMemory() {
|
public MemoryInterface getMemory() {
|
||||||
return memory;
|
return memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,6 +100,10 @@ import org.contikios.cooja.VisPlugin;
|
|||||||
import org.contikios.cooja.dialogs.TableColumnAdjuster;
|
import org.contikios.cooja.dialogs.TableColumnAdjuster;
|
||||||
import org.contikios.cooja.dialogs.UpdateAggregator;
|
import org.contikios.cooja.dialogs.UpdateAggregator;
|
||||||
import org.contikios.cooja.interfaces.IPAddress;
|
import org.contikios.cooja.interfaces.IPAddress;
|
||||||
|
import org.contikios.cooja.mote.memory.MemoryBuffer;
|
||||||
|
import org.contikios.cooja.mote.memory.MemoryInterface;
|
||||||
|
import org.contikios.cooja.mote.memory.MemoryInterface.SegmentMonitor;
|
||||||
|
import org.contikios.cooja.mote.memory.VarMemory;
|
||||||
import org.contikios.cooja.motes.AbstractEmulatedMote;
|
import org.contikios.cooja.motes.AbstractEmulatedMote;
|
||||||
import org.contikios.cooja.util.ArrayQueue;
|
import org.contikios.cooja.util.ArrayQueue;
|
||||||
import org.contikios.cooja.util.StringUtils;
|
import org.contikios.cooja.util.StringUtils;
|
||||||
@ -695,24 +699,24 @@ public class BufferListener extends VisPlugin {
|
|||||||
|
|
||||||
private void registerSegmentMonitor(int size, boolean notify) throws Exception {
|
private void registerSegmentMonitor(int size, boolean notify) throws Exception {
|
||||||
byte[] pointerValue = mote.getMemory().getMemorySegment(pointerAddress, pointerSize);
|
byte[] pointerValue = mote.getMemory().getMemorySegment(pointerAddress, pointerSize);
|
||||||
int segmentAddress = mote.getMemory().parseInt(pointerValue);
|
int segmentAddress = MemoryBuffer.wrap(mote.getMemory().getLayout(), pointerValue).getInt();
|
||||||
|
|
||||||
segmentMonitor = new SegmentMemoryMonitor(bl, mote, segmentAddress, size);
|
segmentMonitor = new SegmentMemoryMonitor(bl, mote, segmentAddress, size);
|
||||||
if (notify) {
|
if (notify) {
|
||||||
segmentMonitor.memoryChanged(mote.getMemory(), MemoryEventType.WRITE, -1);
|
segmentMonitor.memoryChanged(mote.getMemory(), EventType.WRITE, -1);
|
||||||
}
|
}
|
||||||
lastSegmentAddress = segmentAddress;
|
lastSegmentAddress = segmentAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final public void memoryChanged(MoteMemory memory,
|
final public void memoryChanged(MemoryInterface memory,
|
||||||
org.contikios.cooja.MoteMemory.MemoryEventType type, int address) {
|
EventType type, long address) {
|
||||||
if (type == MemoryEventType.READ) {
|
if (type == EventType.READ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] pointerValue = mote.getMemory().getMemorySegment(pointerAddress, pointerSize);
|
byte[] pointerValue = mote.getMemory().getMemorySegment(pointerAddress, pointerSize);
|
||||||
int segmentAddress = mote.getMemory().parseInt(pointerValue);
|
int segmentAddress = MemoryBuffer.wrap(mote.getMemory().getLayout(), pointerValue).getInt();
|
||||||
if (segmentAddress == lastSegmentAddress) {
|
if (segmentAddress == lastSegmentAddress) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -738,7 +742,7 @@ public class BufferListener extends VisPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class SegmentMemoryMonitor implements org.contikios.cooja.MoteMemory.MemoryMonitor {
|
static class SegmentMemoryMonitor implements SegmentMonitor {
|
||||||
protected final BufferListener bl;
|
protected final BufferListener bl;
|
||||||
protected final Mote mote;
|
protected final Mote mote;
|
||||||
|
|
||||||
@ -755,7 +759,7 @@ public class BufferListener extends VisPlugin {
|
|||||||
this.size = size;
|
this.size = size;
|
||||||
|
|
||||||
if (address != 0) {
|
if (address != 0) {
|
||||||
if (!mote.getMemory().addMemoryMonitor(address, size, this)) {
|
if (!mote.getMemory().addSegmentMonitor(SegmentMonitor.EventType.WRITE, address, size, this)) {
|
||||||
throw new Exception("Could not register memory monitor on: " + mote);
|
throw new Exception("Could not register memory monitor on: " + mote);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -776,18 +780,18 @@ public class BufferListener extends VisPlugin {
|
|||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
if (address != 0) {
|
if (address != 0) {
|
||||||
mote.getMemory().removeMemoryMonitor(address, size, this);
|
mote.getMemory().removeSegmentMonitor(address, size, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void memoryChanged(MoteMemory memory, MemoryEventType type, int address) {
|
public void memoryChanged(MemoryInterface memory, EventType type, long address) {
|
||||||
byte[] newData = getAddress()==0?null:mote.getMemory().getMemorySegment(getAddress(), getSize());
|
byte[] newData = getAddress()==0?null:mote.getMemory().getMemorySegment(getAddress(), getSize());
|
||||||
addBufferAccess(bl, mote, oldData, newData, type, this.address);
|
addBufferAccess(bl, mote, oldData, newData, type, this.address);
|
||||||
oldData = newData;
|
oldData = newData;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addBufferAccess(BufferListener bl, Mote mote, byte[] oldData, byte[] newData, MemoryEventType type, int address) {
|
void addBufferAccess(BufferListener bl, Mote mote, byte[] oldData, byte[] newData, EventType type, int address) {
|
||||||
BufferAccess ba = new BufferAccess(
|
BufferAccess ba = new BufferAccess(
|
||||||
mote,
|
mote,
|
||||||
mote.getSimulation().getSimulationTime(),
|
mote.getSimulation().getSimulationTime(),
|
||||||
@ -957,7 +961,7 @@ public class BufferListener extends VisPlugin {
|
|||||||
public boolean include(RowFilter.Entry<? extends Object, ? extends Object> entry) {
|
public boolean include(RowFilter.Entry<? extends Object, ? extends Object> entry) {
|
||||||
if (hideReads) {
|
if (hideReads) {
|
||||||
int row = (Integer) entry.getIdentifier();
|
int row = (Integer) entry.getIdentifier();
|
||||||
if (logs.get(row).type == MemoryEventType.READ) {
|
if (logs.get(row).type == SegmentMonitor.EventType.READ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1013,13 +1017,13 @@ public class BufferListener extends VisPlugin {
|
|||||||
public final byte[] mem;
|
public final byte[] mem;
|
||||||
private boolean[] accessedBitpattern = null;
|
private boolean[] accessedBitpattern = null;
|
||||||
|
|
||||||
public final MemoryEventType type;
|
public final SegmentMonitor.EventType type;
|
||||||
public final String sourceStr;
|
public final String sourceStr;
|
||||||
public final String stackTrace;
|
public final String stackTrace;
|
||||||
public final int address;
|
public final int address;
|
||||||
|
|
||||||
public BufferAccess(
|
public BufferAccess(
|
||||||
Mote mote, long time, int address, byte[] newData, byte[] oldData, MemoryEventType type, boolean withStackTrace) {
|
Mote mote, long time, int address, byte[] newData, byte[] oldData, SegmentMonitor.EventType type, boolean withStackTrace) {
|
||||||
this.mote = mote;
|
this.mote = mote;
|
||||||
this.time = time;
|
this.time = time;
|
||||||
this.mem = newData==null?NULL_DATA:newData;
|
this.mem = newData==null?NULL_DATA:newData;
|
||||||
@ -1538,7 +1542,7 @@ public class BufferListener extends VisPlugin {
|
|||||||
bl,
|
bl,
|
||||||
mote,
|
mote,
|
||||||
getPointerAddress(mote),
|
getPointerAddress(mote),
|
||||||
mote.getMemory().getIntegerLength(),
|
mote.getMemory().getLayout().intSize,
|
||||||
getSize(mote)
|
getSize(mote)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1622,16 +1626,18 @@ public class BufferListener extends VisPlugin {
|
|||||||
|
|
||||||
@ClassDescription("Integer array")
|
@ClassDescription("Integer array")
|
||||||
public static class IntegerParser extends StringParser {
|
public static class IntegerParser extends StringParser {
|
||||||
|
private VarMemory varMem = new VarMemory(null);
|
||||||
@Override
|
@Override
|
||||||
public String parseString(BufferAccess ba) {
|
public String parseString(BufferAccess ba) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
varMem.associateMemory(ba.mote.getMemory());
|
||||||
|
|
||||||
int intLen = ba.mote.getMemory().getIntegerLength();
|
int intLen = ba.mote.getMemory().getLayout().intSize;
|
||||||
sb.append("<html>");
|
sb.append("<html>");
|
||||||
for (int i=0; i < ba.mem.length/intLen; i++) {
|
for (int i=0; i < ba.mem.length/intLen; i++) {
|
||||||
byte[] mem = Arrays.copyOfRange(ba.mem, i*intLen,(i+1)*intLen);
|
byte[] mem = Arrays.copyOfRange(ba.mem, i*intLen,(i+1)*intLen);
|
||||||
boolean[] diff = Arrays.copyOfRange(ba.getAccessedBitpattern(), i*intLen,(i+1)*intLen);
|
boolean[] diff = Arrays.copyOfRange(ba.getAccessedBitpattern(), i*intLen,(i+1)*intLen);
|
||||||
int val = ba.mote.getMemory().parseInt(mem);
|
int val = MemoryBuffer.wrap(ba.mote.getMemory().getLayout(), mem).getInt();
|
||||||
|
|
||||||
boolean red = false;
|
boolean red = false;
|
||||||
for (boolean changed: diff) {
|
for (boolean changed: diff) {
|
||||||
@ -1802,14 +1808,14 @@ public class BufferListener extends VisPlugin {
|
|||||||
public static class NodeIDBuffer extends SegmentBuffer {
|
public static class NodeIDBuffer extends SegmentBuffer {
|
||||||
@Override
|
@Override
|
||||||
public int getAddress(Mote mote) {
|
public int getAddress(Mote mote) {
|
||||||
if (!mote.getMemory().variableExists("node_id")) {
|
if (!mote.getMemory().getSymbolMap().containsKey("node_id")) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return mote.getMemory().getVariableAddress("node_id");
|
return (int) mote.getMemory().getSymbolMap().get("node_id").addr;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int getSize(Mote mote) {
|
public int getSize(Mote mote) {
|
||||||
return mote.getMemory().getIntegerLength();
|
return mote.getMemory().getLayout().intSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1818,11 +1824,11 @@ public class BufferListener extends VisPlugin {
|
|||||||
public static class Queuebuf0Buffer extends SegmentBuffer {
|
public static class Queuebuf0Buffer extends SegmentBuffer {
|
||||||
@Override
|
@Override
|
||||||
public int getAddress(Mote mote) {
|
public int getAddress(Mote mote) {
|
||||||
if (!mote.getMemory().variableExists("buframmem")) {
|
if (!mote.getMemory().getSymbolMap().containsKey("buframmem")) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
return mote.getMemory().getVariableAddress("buframmem") + offset;
|
return (int) mote.getMemory().getSymbolMap().get("buframmem").addr + offset;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int getSize(Mote mote) {
|
public int getSize(Mote mote) {
|
||||||
@ -1834,10 +1840,10 @@ public class BufferListener extends VisPlugin {
|
|||||||
public static class PacketbufBuffer extends SegmentBuffer {
|
public static class PacketbufBuffer extends SegmentBuffer {
|
||||||
@Override
|
@Override
|
||||||
public int getAddress(Mote mote) {
|
public int getAddress(Mote mote) {
|
||||||
if (!mote.getMemory().variableExists("packetbuf_aligned")) {
|
if (!mote.getMemory().getSymbolMap().containsKey("packetbuf_aligned")) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return mote.getMemory().getVariableAddress("packetbuf_aligned");
|
return (int) mote.getMemory().getSymbolMap().get("packetbuf_aligned").addr;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int getSize(Mote mote) {
|
public int getSize(Mote mote) {
|
||||||
@ -1847,19 +1853,21 @@ public class BufferListener extends VisPlugin {
|
|||||||
|
|
||||||
@ClassDescription("*packetbufptr")
|
@ClassDescription("*packetbufptr")
|
||||||
public static class PacketbufPointerBuffer extends PointerBuffer {
|
public static class PacketbufPointerBuffer extends PointerBuffer {
|
||||||
|
VarMemory varMem = new VarMemory(null);
|
||||||
@Override
|
@Override
|
||||||
public int getPointerAddress(Mote mote) {
|
public int getPointerAddress(Mote mote) {
|
||||||
if (!mote.getMemory().variableExists("packetbufptr")) {
|
if (!mote.getMemory().getSymbolMap().containsKey("packetbufptr")) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return mote.getMemory().getVariableAddress("packetbufptr");
|
return (int) mote.getMemory().getSymbolMap().get("packetbufptr").addr;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int getAddress(Mote mote) {
|
public int getAddress(Mote mote) {
|
||||||
if (!mote.getMemory().variableExists("packetbufptr")) {
|
if (!mote.getMemory().getSymbolMap().containsKey("packetbufptr")) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return mote.getMemory().getIntValueOf("packetbufptr");
|
varMem.associateMemory(mote.getMemory());
|
||||||
|
return varMem.getIntValueOf("packetbufptr");
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int getSize(Mote mote) {
|
public int getSize(Mote mote) {
|
||||||
@ -1872,23 +1880,25 @@ public class BufferListener extends VisPlugin {
|
|||||||
public String variable;
|
public String variable;
|
||||||
public int size;
|
public int size;
|
||||||
public int offset;
|
public int offset;
|
||||||
|
VarMemory varMem = new VarMemory(null);
|
||||||
@Override
|
@Override
|
||||||
public int getPointerAddress(Mote mote) {
|
public int getPointerAddress(Mote mote) {
|
||||||
if (!mote.getMemory().variableExists(variable)) {
|
if (!mote.getMemory().getSymbolMap().containsKey(variable)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return mote.getMemory().getVariableAddress(variable);
|
return (int) mote.getMemory().getSymbolMap().get(variable).addr;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int getAddress(Mote mote) {
|
public int getAddress(Mote mote) {
|
||||||
if (!mote.getMemory().variableExists(variable)) {
|
if (!mote.getMemory().getSymbolMap().containsKey(variable)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return mote.getMemory().getIntValueOf(variable)+offset;
|
varMem.associateMemory(mote.getMemory());
|
||||||
|
return varMem.getIntValueOf(variable)+offset;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int getSize(Mote mote) {
|
public int getSize(Mote mote) {
|
||||||
if (!mote.getMemory().variableExists(variable)) {
|
if (!mote.getMemory().getSymbolMap().containsKey(variable)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
@ -1968,14 +1978,14 @@ public class BufferListener extends VisPlugin {
|
|||||||
public int offset;
|
public int offset;
|
||||||
@Override
|
@Override
|
||||||
public int getAddress(Mote mote) {
|
public int getAddress(Mote mote) {
|
||||||
if (!mote.getMemory().variableExists(variable)) {
|
if (!mote.getMemory().getSymbolMap().containsKey(variable)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return mote.getMemory().getVariableAddress(variable)+offset;
|
return (int) mote.getMemory().getSymbolMap().get(variable).addr+offset;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int getSize(Mote mote) {
|
public int getSize(Mote mote) {
|
||||||
if (!mote.getMemory().variableExists(variable)) {
|
if (!mote.getMemory().getSymbolMap().containsKey(variable)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
@ -2052,14 +2062,14 @@ public class BufferListener extends VisPlugin {
|
|||||||
public String variable;
|
public String variable;
|
||||||
@Override
|
@Override
|
||||||
public int getAddress(Mote mote) {
|
public int getAddress(Mote mote) {
|
||||||
if (!mote.getMemory().variableExists(variable)) {
|
if (!mote.getMemory().getSymbolMap().containsKey(variable)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return mote.getMemory().getVariableAddress(variable);
|
return (int) mote.getMemory().getSymbolMap().get(variable).addr;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int getSize(Mote mote) {
|
public int getSize(Mote mote) {
|
||||||
return mote.getMemory().getIntegerLength();
|
return mote.getMemory().getLayout().intSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user