synchronizing pending bytes vector

This commit is contained in:
fros4943 2008-12-04 13:09:27 +00:00
parent 5e6b02d1b9
commit cdd2d9daa5

View file

@ -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.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; package se.sics.cooja.mspmote.interfaces;
@ -134,15 +134,19 @@ public class SkySerial extends Log implements SerialPort, USARTListener {
} }
private void tryWriteNextByte() { private void tryWriteNextByte() {
if (incomingData.isEmpty()) { byte b;
return;
}
if (!usart.isReceiveFlagCleared()) {
return;
}
/* Write byte to serial port */ synchronized (incomingData) {
byte b = incomingData.remove(0); if (!usart.isReceiveFlagCleared()) {
return;
}
if (incomingData.isEmpty()) {
return;
}
/* Write byte to serial port */
b = incomingData.remove(0);
}
usart.byteReceived(b); usart.byteReceived(b);
} }