milliseconds -> microseconds update
This commit is contained in:
parent
62db437c2d
commit
c59fc91487
|
@ -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: MicaClock.java,v 1.2 2009/03/11 14:12:19 fros4943 Exp $
|
* $Id: MicaClock.java,v 1.3 2009/05/26 14:35:52 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.avrmote.interfaces;
|
package se.sics.cooja.avrmote.interfaces;
|
||||||
|
@ -63,12 +63,12 @@ public class MicaClock extends Clock {
|
||||||
return time > 0 ? time : 0;
|
return time > 0 ? time : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDrift(int drift) {
|
public void setDrift(long drift) {
|
||||||
myMote.cycleDrift = MicaZMote.NR_CYCLES_PER_MSEC * drift;
|
myMote.cycleDrift = Simulation.MILLISECOND * MicaZMote.NR_CYCLES_PER_MSEC * drift;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDrift() {
|
public long getDrift() {
|
||||||
return (int) (myMote.cycleDrift / MicaZMote.NR_CYCLES_PER_MSEC);
|
return (long) ((double)myMote.cycleDrift / MicaZMote.NR_CYCLES_PER_MSEC / Simulation.MILLISECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JPanel getInterfaceVisualizer() {
|
public JPanel getInterfaceVisualizer() {
|
||||||
|
|
|
@ -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: MspClock.java,v 1.8 2009/03/09 17:14:35 fros4943 Exp $
|
* $Id: MspClock.java,v 1.9 2009/05/26 14:31:07 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.mspmote.interfaces;
|
package se.sics.cooja.mspmote.interfaces;
|
||||||
|
@ -61,16 +61,16 @@ public class MspClock extends Clock {
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getTime() {
|
public long getTime() {
|
||||||
int time = (int) ((cpu.cycles + myMote.cycleDrift) / MspMote.NR_CYCLES_PER_MSEC);
|
long time = (long) ((double)cpu.cycles * Simulation.MILLISECOND / MspMote.NR_CYCLES_PER_MSEC);
|
||||||
return time > 0 ? time : 0;
|
return time > 0 ? time : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDrift(int drift) {
|
public void setDrift(long drift) {
|
||||||
myMote.cycleDrift = MspMote.NR_CYCLES_PER_MSEC * drift;
|
myMote.usDrift = drift;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDrift() {
|
public long getDrift() {
|
||||||
return (int) (myMote.cycleDrift / MspMote.NR_CYCLES_PER_MSEC);
|
return myMote.usDrift;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JPanel getInterfaceVisualizer() {
|
public JPanel getInterfaceVisualizer() {
|
||||||
|
|
|
@ -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: MspMoteID.java,v 1.11 2009/03/09 16:05:11 fros4943 Exp $
|
* $Id: MspMoteID.java,v 1.12 2009/05/26 14:31:07 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.mspmote.interfaces;
|
package se.sics.cooja.mspmote.interfaces;
|
||||||
|
@ -41,6 +41,7 @@ import org.apache.log4j.Logger;
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
|
|
||||||
import se.sics.cooja.Mote;
|
import se.sics.cooja.Mote;
|
||||||
|
import se.sics.cooja.Simulation;
|
||||||
import se.sics.cooja.TimeEvent;
|
import se.sics.cooja.TimeEvent;
|
||||||
import se.sics.cooja.interfaces.MoteID;
|
import se.sics.cooja.interfaces.MoteID;
|
||||||
import se.sics.cooja.mspmote.MspMote;
|
import se.sics.cooja.mspmote.MspMote;
|
||||||
|
@ -118,7 +119,7 @@ public class MspMoteID extends MoteID {
|
||||||
/*logger.debug("ID location: " + location);*/
|
/*logger.debug("ID location: " + location);*/
|
||||||
|
|
||||||
if (PERSISTENT_SET_ID) {
|
if (PERSISTENT_SET_ID) {
|
||||||
mote.getSimulation().scheduleEvent(persistentSetIDEvent, mote.getSimulation().getSimulationTime()+1);
|
mote.getSimulation().scheduleEvent(persistentSetIDEvent, mote.getSimulation().getSimulationTime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,12 +129,13 @@ public class MspMoteID extends MoteID {
|
||||||
if (persistentSetIDCounter-- > 0)
|
if (persistentSetIDCounter-- > 0)
|
||||||
{
|
{
|
||||||
setMoteID(moteID);
|
setMoteID(moteID);
|
||||||
/*logger.debug("Persistent set ID: " + moteID);*/
|
/*logger.info("Setting ID: " + moteID + " at " + t);*/
|
||||||
|
|
||||||
if (t < -mote.getInterfaces().getClock().getDrift()) {
|
if (t + mote.getInterfaces().getClock().getDrift() < 0) {
|
||||||
|
/* Wait until node is booting */
|
||||||
mote.getSimulation().scheduleEvent(this, -mote.getInterfaces().getClock().getDrift());
|
mote.getSimulation().scheduleEvent(this, -mote.getInterfaces().getClock().getDrift());
|
||||||
} else {
|
} else {
|
||||||
mote.getSimulation().scheduleEvent(this, t+1);
|
mote.getSimulation().scheduleEvent(this, t+Simulation.MILLISECOND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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: SkySerial.java,v 1.14 2009/03/09 17:14:35 fros4943 Exp $
|
* $Id: SkySerial.java,v 1.15 2009/05/26 14:31:07 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.mspmote.interfaces;
|
package se.sics.cooja.mspmote.interfaces;
|
||||||
|
@ -56,6 +56,8 @@ import se.sics.cooja.plugins.SLIP;
|
||||||
*/
|
*/
|
||||||
@ClassDescription("Serial port")
|
@ClassDescription("Serial port")
|
||||||
public class SkySerial extends Log implements SerialPort, USARTListener {
|
public class SkySerial extends Log implements SerialPort, USARTListener {
|
||||||
|
private static final long DELAY_INCOMING_DATA = 69; /* Corresponds to 115200 bit/s */
|
||||||
|
|
||||||
private static Logger logger = Logger.getLogger(SkySerial.class);
|
private static Logger logger = Logger.getLogger(SkySerial.class);
|
||||||
|
|
||||||
private SkyMote mote;
|
private SkyMote mote;
|
||||||
|
@ -104,7 +106,6 @@ public class SkySerial extends Log implements SerialPort, USARTListener {
|
||||||
|
|
||||||
public void writeByte(byte b) {
|
public void writeByte(byte b) {
|
||||||
incomingData.add(b);
|
incomingData.add(b);
|
||||||
tryWriteNextByte();
|
|
||||||
mote.getSimulation().scheduleEvent(writeDataEvent, mote.getSimulation().getSimulationTime());
|
mote.getSimulation().scheduleEvent(writeDataEvent, mote.getSimulation().getSimulationTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +158,7 @@ public class SkySerial extends Log implements SerialPort, USARTListener {
|
||||||
public void execute(long t) {
|
public void execute(long t) {
|
||||||
tryWriteNextByte();
|
tryWriteNextByte();
|
||||||
if (!incomingData.isEmpty()) {
|
if (!incomingData.isEmpty()) {
|
||||||
mote.getSimulation().scheduleEvent(this, t+1);
|
mote.getSimulation().scheduleEvent(this, t+DELAY_INCOMING_DATA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue