mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-11-19 03:05:14 +00:00
fixed bug in the delayed start of MSPSim motes
This commit is contained in:
parent
fc85534698
commit
ee56d724bf
@ -26,7 +26,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: MspMote.java,v 1.9 2008/09/17 12:09:20 fros4943 Exp $
|
||||
* $Id: MspMote.java,v 1.10 2008/09/17 17:39:37 nifi Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.mspmote;
|
||||
@ -53,6 +53,7 @@ public abstract class MspMote implements Mote {
|
||||
|
||||
/* Cycle counter */
|
||||
public long cycleCounter = 0;
|
||||
public int cycleDrift = 0;
|
||||
|
||||
private Simulation mySimulation = null;
|
||||
private MSP430 myCpu = null;
|
||||
@ -276,7 +277,7 @@ public abstract class MspMote implements Mote {
|
||||
}
|
||||
|
||||
long maxSimTimeCycles = NR_CYCLES_PER_MSEC*(simTime+1);
|
||||
if (maxSimTimeCycles <= cycleCounter) {
|
||||
if (maxSimTimeCycles <= cycleCounter - cycleDrift) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: MspClock.java,v 1.1 2008/02/07 14:54:16 fros4943 Exp $
|
||||
* $Id: MspClock.java,v 1.2 2008/09/17 17:39:37 nifi Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.mspmote.interfaces;
|
||||
@ -61,11 +61,12 @@ public class MspClock extends Clock {
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return (int) (cpu.cycles / MspMote.NR_CYCLES_PER_MSEC);
|
||||
int time = (int) ((cpu.cycles + myMote.cycleDrift) / MspMote.NR_CYCLES_PER_MSEC);
|
||||
return time > 0 ? time : 0;
|
||||
}
|
||||
|
||||
public void setDrift(int drift) {
|
||||
myMote.cycleCounter = -MspMote.NR_CYCLES_PER_MSEC * drift;
|
||||
myMote.cycleDrift = MspMote.NR_CYCLES_PER_MSEC * drift;
|
||||
}
|
||||
|
||||
public void doActionsBeforeTick() {
|
||||
|
Loading…
Reference in New Issue
Block a user