[Tinyos-2.0wg] Re: TX done notification in serial stack

Ben Greenstein bengreenstein at gmail.com
Tue Jul 11 22:59:24 PDT 2006


I think it was David Gay who said he thought it might not be a good
idea to adjust the wire protocol to ignore garbage. I agree. That
leaves the option of spinning.

To keep the discussion rolling, here are 5 ways to spin, none of which
are particularly great. I like 2 and 5:

1) We spin until TX_EMPTY is asserted before signalling txDone. This
is obviously inefficient as it effectively annihilates double
buffering. In the case of msp430:

  TOSH_SIGNAL(UART1TX_VECTOR) {
    while (!TX_EMPTY);
    signal UsartInterrupts.txDone();
  }

2) The spinning could come synchronously after the txDone signal, but
would require the next byte (if there is one) also to be sent
synchronously with respect to the txDone signal. (Otherwise, the
effect is the same as 1.)

  TOSH_SIGNAL(UART1TX_VECTOR) {
    signal UsartInterrupts.txDone();
    while (ANOTHER_BYTE_HASNT_BEEN_PUT && !TX_EMPTY);
    if (TX_EMPTY) signal UsartInterrupts.txIdle()
  }

3) The spinning is requested; the upper layer calls idleTx()?. The
implementation of this call contains the spin. The return is the
answer: No, if another byte is put while spinning. Yes after spinning,
if not.

4) Same as 3, except that instead of returning the idleness, a txIdle
event is signalled.

5) Same as 4, except that the spinning is from within a task posted by
the idleTx() implementation.


On 7/7/06, Vlado Handziski <handzisk at tkn.tu-berlin.de> wrote:
> On 7/7/06, Ben Greenstein <bengreenstein at gmail.com> wrote:
> >
> > Vlado,
> > Would you like to start a discussion on your proposed serial communication
> enhancements?
>
>
> I don't have much additional insight than what is in the call notes. I think
> it is obvious that there are situations when we need explicit information
> that the data sent over the UART has actually been transmitted in full (like
> before powering the usart down, when switching from TX to RX on a radio with
> UART data line, etc.) On platforms that don't have double buffering, we can
> use the putDone event but putDone does not guarantee that the data is sent
> on double buffered MCUs (both the atmega and the msp430 are double
> buffered).
>
> The issue is how to push this notification to the higher layers (above HPL).
> Some MCUs have explicit interrupt (the atmega) that can be translated into
> an event (txDone or txEmpty) and propagated to the higher levels.  The
> msp430 is not generating a HW interrupt when the TX is empty, it only
> provides a flag that can be polled. The obvious solution here would be to
> loop on the flag, but depending on the speed of the UART this can take a
> significant amount of time. Alternatively, one can push a dummy byte at the
> end of the transmission, to flush the real data out, and use the putDone
> after the dummy byte as indication that the real data has been sent.
> Unfortunately some of the dummy info will leak on the line, so the other
> side has to be able to safely ignore this garbage.
>
> So both solutions have significant shortcomings, and I don't see a way how
> this can be handled nicely on the non-interrupt capable MCUs.
>
> Vlado
>
>
>
>
>


More information about the Tinyos-2.0wg mailing list