In article <11*********************@f14g2000cwb.googlegroups. com>,
vib <vi*****@gmail.com> wrote:
Any benefits of using this method?
Which method? You did not quote any context, and I've read approximately
118 postings and 1063 email messages since your previous message.
Just thinking using a simple, easy
understand method, like writting to a circular buffer, and the TX empty
interrupt may read the circular buffer and send it to the UART. Simple
yet easy to implement.
UART... TX buffer... lemme rummage through my memory.
The layer you are neglecting is the -formatting- of the data to
write to the buffer. That's what the code you pointed to before
takes care of. It isn't until about 3 layers down that it gets to
the transmission of bytes to the UART, and it does that by way of
the UART_Send routine that we aren't shown the implementation of.
Whether the UART_Send works on a circular buffer or something else
is transparent to this level of code.
You shouldn't be looking at the va_* code as having anything to do
with the complicating of the routine. It -is- a "simple, easy understand"
method at the upper level. Your code just calls the debug
printf layer and passes whatever format string and argument that
it needs, and everything else is automagically taken care of.
You only need to get down to the lower level if you are the person
who has to implement the circular buffer or whatever...
If you -are- the person who needs to implement a circular buffer,
then consider exactly what the user interface would be. If the
circular buffer is partly full at the moment, and I ask to add
something to it, then suppose what I'm adding is too big to fit
into the buffer all at one time. What is your routine going to do then?
Reject the entire string that I want to add? Add what it can
and return the count (or buffer pointer) to the rest? Add what
it can at the moment, sleep a bit and add some more, and so on until
the entire message is inserted? One of the simplest insertion
mechanisms is to check to see if there is room for a byte,
add it if so, and if not then wait for a signal from the writing
routine saying it pulled something out of the buffer (or for
a sanity alarm in case that signal got lost somehow.) And that's
effectively the interface that this code has presented, with it's
preperation of the output string first and then looping sending each
byte in sequence using some unspecified transmission mechanism.
--
Okay, buzzwords only. Two syllables, tops. -- Laurie Anderson