Your code example looks decent, but there is also another option.
const DEBUG_ENABLE = TRUE
if DEBUG_ENABLE == TRUE then
alias debug_1_byte_dec is print_byte_dec
else
procedure debug_1_byte_dec(byte out device, byte in data) is
pragma inline
end procedure
end if
You can also still do this if you like:
alias debug_stream is serial_hw_data
I'm not sure if this will actually use any extra bytes of data or
processing power, I can test it. I guess I actually need a "pragma
ignore" to ignore the entire procedure.
The advantage in my example is that the debug library will have
exactly the same API as print.
I don't care either way. What does everyone prefer??
Matt.
On Sep 7, 1:34 pm, Joep Suijs <[email protected]> wrote:
> Sorry, previous message was sent before it was complete...
>
> Hi,
>
> You're right: alias is a way to create a generic device.
>
> So something like (not checked):
>
> alias debug_stream is serial_hw_data
>
> const enable_debug = 1
> var bit debug_level[10]
>
> procedure debug_byte_dec(byte in level, byte in data) is
> pragma inline
>
> if (enable_debug) then
> if (debug_level[level]) then
> print_byte_dec(debug_stream, data)
> end if
> end if
>
> end procedure
>
> So:
> - enable_debug = 0 will remove most of the code (compile time enable/disable
> - the inline statement might or might not be a good idea. you should
> check what the efffect is on code and ram size, both with enable_debug
> 0 and 1. It does save a stack level
> - debug_level[x] = true / false allows runtime enble/disable of a
> group of levels.
> - the global use of debug_stream will save some code and ram space.
>
> Anyway, lots of print statement are an efficient way to drain your
> resources (trust me, I know ;) and a library like this will add some
> to this. But on the other hand, good debug aids are very valuable and
> printing to the serial port is my #1 debug tool (but I'd love to hear
> how I could use tools with breakpoints and single step in more complex
> apps!).
>
> Joep
--
You received this message because you are subscribed to the Google Groups
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jallib?hl=en.