lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Thijs Schreijer <thijs@thijsschreijer.nl> [14-03-11 19:04]:
> > -----Original Message-----
> > From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On
> > Behalf Of meino.cramer@gmx.de
> > Sent: dinsdag 11 maart 2014 18:26
> > To: Lua mailing list
> > Subject: Most efficient way to recognize a line by its first (up to) three
> > characters
> > 
> > 
> > Hi,
> > 
> > (using Lua 5.2.2 under Linux)
> > 
> > from a serial line I receive A LOT of lines
> > consisting of data in ASCII format.
> > 
> > The first one to three characters decide, how
> > I have to interpret the data.
> > Since data are transmitted FAST I want to make
> > the recognition code which branches into the
> > different data processing parts as efficient
> > as possible. The code will run on a embedded
> > system, so I will not have the memory for huge
> > look-up table or such...
> > And I will do it in pure Lua since this is the
> > reason why I do this in pure Lua! ;)
> > 
> > What is the "best" solution?
> > ('best' in "" since this also a product of the
> > point of view ;)
> > 
> > Thank you very much for any help in advance!
> > Best regards,
> > mcc
> > 
> 
> How many branch possibilities will each byte/character have? And what do you consider 'huge' for a lookup table?
> 
> 
> 

There are either a one character or a two character or a three
character code at the beginning of each line, which tells me about
the kind of data to expect after that code.
Huge would be some megabytes.