milliseconds -> microseconds update + removed dependency of radio interface
This commit is contained in:
parent
a7faaa9aaa
commit
e238d84a75
1 changed files with 9 additions and 19 deletions
|
@ -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: MspMote.java,v 1.28 2009/04/29 20:04:56 fros4943 Exp $
|
* $Id: MspMote.java,v 1.29 2009/05/26 14:34:30 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.mspmote;
|
package se.sics.cooja.mspmote;
|
||||||
|
@ -71,7 +71,7 @@ public abstract class MspMote implements Mote {
|
||||||
|
|
||||||
/* Cycle counter */
|
/* Cycle counter */
|
||||||
public long cycleCounter = 0;
|
public long cycleCounter = 0;
|
||||||
public long cycleDrift = 0;
|
public long usDrift = 0; /* us */
|
||||||
|
|
||||||
private Simulation mySimulation = null;
|
private Simulation mySimulation = null;
|
||||||
private CommandHandler commandHandler;
|
private CommandHandler commandHandler;
|
||||||
|
@ -300,22 +300,17 @@ public abstract class MspMote implements Mote {
|
||||||
private int[] pcHistory = new int[5];
|
private int[] pcHistory = new int[5];
|
||||||
|
|
||||||
/* return false when done - e.g. true means more work to do before finished with this tick */
|
/* return false when done - e.g. true means more work to do before finished with this tick */
|
||||||
private boolean firstTick = true;
|
|
||||||
public boolean tick(long simTime) {
|
public boolean tick(long simTime) {
|
||||||
if (stopNextInstruction) {
|
if (stopNextInstruction) {
|
||||||
stopNextInstruction = false;
|
stopNextInstruction = false;
|
||||||
throw new RuntimeException("MSPSim requested simulation stop");
|
throw new RuntimeException("MSPSim requested simulation stop");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (simTime + usDrift < 0) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Nodes may be added in an ongoing simulation:
|
long maxSimTimeCycles = (long)(NR_CYCLES_PER_MSEC * ((simTime+usDrift+Simulation.MILLISECOND)/(double)Simulation.MILLISECOND));
|
||||||
* Update cycle drift to current simulation time */
|
|
||||||
if (firstTick) {
|
|
||||||
firstTick = false;
|
|
||||||
cycleDrift += (-NR_CYCLES_PER_MSEC*simTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
long maxSimTimeCycles = NR_CYCLES_PER_MSEC * (simTime + 1) + cycleDrift;
|
|
||||||
|
|
||||||
if (maxSimTimeCycles <= cycleCounter) {
|
if (maxSimTimeCycles <= cycleCounter) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -330,7 +325,7 @@ public abstract class MspMote implements Mote {
|
||||||
}
|
}
|
||||||
myMoteInterfaceHandler.doActiveActionsBeforeTick();
|
myMoteInterfaceHandler.doActiveActionsBeforeTick();
|
||||||
|
|
||||||
/* Experimental program counter history */
|
/* Log recent program counter (PC) history */
|
||||||
for (int i=pcHistory.length-1; i > 0; i--) {
|
for (int i=pcHistory.length-1; i > 0; i--) {
|
||||||
pcHistory[i] = pcHistory[i-1];
|
pcHistory[i] = pcHistory[i-1];
|
||||||
}
|
}
|
||||||
|
@ -359,11 +354,6 @@ public abstract class MspMote implements Mote {
|
||||||
new RuntimeException("Emulated exception: " + e.getMessage()).initCause(e);
|
new RuntimeException("Emulated exception: " + e.getMessage()).initCause(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if radio has pending incoming bytes */
|
|
||||||
if (myRadio != null && myRadio.hasPendingBytes()) {
|
|
||||||
myRadio.tryDeliverNextByte(cpu.cycles);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (monitorStackUsage) {
|
if (monitorStackUsage) {
|
||||||
int newStack = cpu.reg[MSP430.SP];
|
int newStack = cpu.reg[MSP430.SP];
|
||||||
if (newStack < stackPointerLow && newStack > 0) {
|
if (newStack < stackPointerLow && newStack > 0) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue