From 5d6a0736553a16467a65788f25931cf12a036a46 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Wed, 3 Feb 2010 20:00:29 +0000 Subject: [PATCH] bugfix: time event was initialized with null mote --- .../cooja/mspmote/interfaces/MspSerial.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspSerial.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspSerial.java index 1a4bccdd2..9cc2e0a67 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspSerial.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspSerial.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: MspSerial.java,v 1.2 2010/02/03 19:17:30 fros4943 Exp $ + * $Id: MspSerial.java,v 1.3 2010/02/03 20:00:29 fros4943 Exp $ */ package se.sics.cooja.mspmote.interfaces; @@ -62,6 +62,8 @@ public class MspSerial extends SerialUI implements SerialPort { private Vector incomingData = new Vector(); + private TimeEvent writeDataEvent; + public MspSerial(Mote mote) { this.mote = (MspMote) mote; this.simulation = mote.getSimulation(); @@ -81,6 +83,18 @@ public class MspSerial extends SerialUI implements SerialPort { } }); } + + writeDataEvent = new MspMoteTimeEvent((MspMote) mote, 0) { + public void execute(long t) { + super.execute(t); + + tryWriteNextByte(); + if (!incomingData.isEmpty()) { + simulation.scheduleEvent(this, t+DELAY_INCOMING_DATA); + } + } + }; + } public void writeByte(byte b) { @@ -137,17 +151,6 @@ public class MspSerial extends SerialUI implements SerialPort { mote.requestImmediateWakeup(); } - private TimeEvent writeDataEvent = new MspMoteTimeEvent(mote, 0) { - public void execute(long t) { - super.execute(t); - - tryWriteNextByte(); - if (!incomingData.isEmpty()) { - simulation.scheduleEvent(this, t+DELAY_INCOMING_DATA); - } - } - }; - public Mote getMote() { return mote; }