Hi,

I'd like to revisit this to help me understand recognisers since I think
they might be very powerful but I don't yet understand them. If I wanted to
scan the input stream for a specific NMEA sentence and save part of the
input line then could I start with something like this? I followed the
rec:string example though the reason for adding such a large number to the
contents of >in escape me.

I added plenty of comments to help expose the shortcomings in my
understanding so far

Kind regards
Richard

\ define a recogniser for just one of the many NMEA string formats arriving
on the serial port
\ goal is to push latitude onto stack as a double number degrees  minutes,
no seconds
\ $GPGGA,191410,4735.5634,N,00739.3538,E,1,04,4.4,351.5,M,48.0,M,,*45

\ runtime, compile time, and postpone execution tokens
' noop
' dt:dnum
:noname . -48 throw ;

recognizer: r:GPGGA     \ creates a table r:GPGGA

: REC:GPGGA \ ( Addr len --- )
    over c@     \ get first char of input line
    [char] $ <>    \ test if not a $ char
    if    2drop r:fail exit
    then
    negate 1+     \ if len was 80 0b0101 0000 then negate gives 65456 or
0b1111 1111 1011 0000
                  \ 1+ gives 65457 or 0b1111 1111 1011 0001
    >in +!        \ add 65457 to contents of what was saved at address of
>in
    drop          \ drop remaining address on stack
    [char] , parse \ returns addr len of string delimited by , ie if
sentence did start with $GPGGA,19.....
                   \ then address where first G in GPGGA is and length of 5


\ pseudo code follows:
    \ test for GPGGA here.
    \ if not then 2drop r:fail exit
    \ otherwise push the data from the line we want e.g. 47 and 35 onto
stack

    r:GPGGA  \ I am a bit confused over what this does
    ;

' rec:GPGGA get-recognizers 1+ set-recognizers  \ add new recognizer to
list used for testing input stream


On Wed, Jan 6, 2016 at 9:24 PM, Andreas Wagner <
andreas.wag...@lowfatcomputing.org> wrote:

> > Alternatively you could emulate a UART on the simpler AVR as used on the
> Arduino Uno in software (“bit-banging”).  This would be more effort
> software-wise.
>
> Wasn't a soft-UART written as part of the amForth GBoard effort on
> roboforum.ru?
>
> http://roboforum.ru/forum58/topic4406-150.html
>
> https://www.itead.cc/gboard.html
>
> /Andreas
>
>
>
> On Wed, Jan 6, 2016 at 6:46 AM Matthias Trute <mtr...@web.de> wrote:
>
> > Am Mittwoch, den 06.01.2016, 10:30 +0000 schrieb Sven:
> > > Hi,
> > > I have a GPS module with serial NMA0183 output ( 4800 8n1 ) and a
> > > Arduino board with amforth installed.
> > > My idea is to read the NMEA data from the Arduino serial interface
> > > and display it on a LCD, but the serial port is normally used by the
> > > terminal session of amforth. Is it possible to detect a NMEA sentence
> > > like:
> > > $GPGGA,191410,4735.5634,N,00739.3538,E,1,04,4.4,351.5,M,48.0,M,,*45
> > > in the input stream ?
> > > Any ideas ?
> >
> > You could give recognizers a try.
> >
> > http://amforth.sourceforge.net/TG/recipes/Recognizer.html
> > http://amforth.sourceforge.net/Recognizers.html
> > http://sourceforge.net/p/amforth/code/HEAD/tree/trunk/examples/time-rec
> > .frt
> >
> > They are made for such tasks.
> >
> > Matthias
> >
> >
> > ------------------------------------------------------------
> ------------------
> > _______________________________________________
> > Amforth-devel mailing list for http://amforth.sf.net/
> > Amforth-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/amforth-devel
> >
> ------------------------------------------------------------
> ------------------
> _______________________________________________
> Amforth-devel mailing list for http://amforth.sf.net/
> Amforth-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/amforth-devel
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to