From cdd2d9daa551fab43ac9ccf296d90953c2a2f738 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Thu, 4 Dec 2008 13:09:27 +0000 Subject: [PATCH] synchronizing pending bytes vector --- .../cooja/mspmote/interfaces/SkySerial.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkySerial.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkySerial.java index 940b337b3..e700b2be9 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkySerial.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkySerial.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: SkySerial.java,v 1.6 2008/12/03 13:04:21 fros4943 Exp $ + * $Id: SkySerial.java,v 1.7 2008/12/04 13:09:27 fros4943 Exp $ */ package se.sics.cooja.mspmote.interfaces; @@ -134,15 +134,19 @@ public class SkySerial extends Log implements SerialPort, USARTListener { } private void tryWriteNextByte() { - if (incomingData.isEmpty()) { - return; - } - if (!usart.isReceiveFlagCleared()) { - return; - } + byte b; - /* Write byte to serial port */ - byte b = incomingData.remove(0); + synchronized (incomingData) { + if (!usart.isReceiveFlagCleared()) { + return; + } + if (incomingData.isEmpty()) { + return; + } + + /* Write byte to serial port */ + b = incomingData.remove(0); + } usart.byteReceived(b); }