Re: [PATCH -ac] Panicking in morse code, v2

Daniel Phillips (phillips@arcor.de)
Sat, 20 Jul 2002 12:58:42 +0200


Nice joke. Unfortunately, this code is too useful to ignore. I distinctly
remember finding myself in the position of having completed the firmware of
an embedded device without properly recording the correspondence of led blink
patterns to error codes, the result being that if the firmware had ever failed
(luckily it never did) nobody would have been quite sure why. How much more
useful, satisfying and stylish to have encoded the failure messages in morse.

On Saturday 20 July 2002 01:02, Andrew Rodland wrote:
> Thanks a million to the unnamed linux<AT>horizon.com for some great
> suggestions/info. v2 of the morse-panic patch features better
> punctuation handling, proper morse-like timings, and something like 1/5
> the static data requirement, thanks to the varicode algo that I
> couldn't come up with myself. :)

Indeed, that one had me scratching my head, even with the code in front of
me. Let me describe the encoding method for the benefit of anybody not
energetic or foolish enough to puzzle it out for themselves:

- The sequence is encoded from low bit to high, zero=dit, one=dah

- The sequence always terminates with a one=dah, which is dropped,
followed by an infinite string of zeros.

The infinite string of zeros is shifted in from the top of the byte, hence
the terminating condition morse <= 1, which prudently covers the impossible
case of morse == 0.

This deserves a comment.

Note that there is a bug waiting to bite: you need to declare morse as
unsigned char, otherwise you will be unable to make good on your claim that
up to 7 morse bits can be encoded.

-- 
Daniel
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/