Rather than trying to read the entire word, use only the first n unique characters. Many systems run on this, ie, 'show' could be entered 'sh' or 'sho' and still count. You are only going to have a small number of commands, and chances are good that the first three letters of each command are unique. If not, use another word which means the same thing. Then you can read three letters into a buffer, check against the table of possibilities (or use a tree), and discard all incoming letters after that until a whitespace. -Adam David VanHorn wrote: > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > I have a somewhat ugly task to take on, and I'm looking for any alternate > approaches before I implement a mess :) > > What I have to do is watch a serial byte stream for commands like: > > offset 20 or > echo on > > I have to pick the commands up, and implement them, as well as reject bad > commands (non-existent or mis-spelled) The particular command handler will > be responsible for sanity-checking the data. > > Is there any clever approach to this, or is it an ugly, brute-force thing? > FWIW, I'm doing this in assembler. > > -----BEGIN PGP SIGNATURE----- > Version: PGPfreeware 6.5.2 for non-commercial use > > iQA/AwUBOOFaKoFlGDz1l6VWEQJSoQCgwoLLc2OUU9j9ufo6H79Oi0R3nTAAoMna > f1Yn85K87RowBRkEMI1NBHsT > =n0uL > -----END PGP SIGNATURE-----