- while (m_slen && call Registers.getIfgTx()) {
- call Registers.setTxbuf(*m_sbuf);
- if (--m_slen)
- m_sbuf++;
- }
- if (m_slen == 0 && m_sobuf) {
- call Registers.clrIeTx();
- m_sobuf = 0;
- signal UartStream.sendDone(m_sobuf, m_solen, SUCCESS);
+ if (m_sobuf) {
+ while (!call Registers.getIfgTx()); /* in case interleaved UB.send */
+ while (m_slen && call Registers.getIfgTx()) {
+ call Registers.setTxbuf(*m_sbuf);
+ if (--m_slen)
+ m_sbuf++;
+ }
+ if (m_slen == 0) {
+ call Registers.clrIeTx();
+ m_sobuf = 0;
+ signal UartStream.sendDone(m_sobuf, m_solen, SUCCESS);
+ }