Hi Matthias,

I can now reliably reproduce the problem with quite a small amount of code
and without the xbee. Because of this I now have the normal forth
interaction which makes debugging easier.

I've put a couple of debugging statements in (evaluate) to try and see
what's going on.

: (evaluate) \ i*x addr len -- j*y
    ." In evaluate" cr                                               \ added
    ['] source defer@ >r
    >in @ >r
    0 >in !
    strlen !
    str !
    ." Source string is: " source-string type cr          \ added
    ['] source-string is source
    ['] interpret catch
    r> >in !
    r> is source
    throw
;

This has proved two things:

1. When the bug occurs, (evaluate) is still being called.
2. The source string is correct also.

My code now looks like this:

VARIABLE ctr
: inctr ( -- )
    ." Incrementing pointer" cr
    ctr @ 1 + ctr !
;

variable my-array 20 allot

: makeinctr ( -- )
    $69 my-array c!
    $6e my-array 1 + c!
    $63 my-array 2 + c!
    $74 my-array 3 + c!
    $72 my-array 4 + c!
;

: runte ( -- )
    applturnkey
    #6 ctr !
    #10 bigloop
    #10 0
    DO
." The value of ctr is " ctr @ . cr
makeinctr my-array 5 (evaluate)
." The new value of ctr is " ctr @ . cr cr
#10 bigloop
    LOOP
;

The bug happens when I run my device off batteries and it has also
occasionally happened on USB power.

When it works (usually on USB power) my code prints the following:
(note - it doesn't start at 6 because it takes a moment for me to open the
USB port in cutecom.)


The value of ctr is 8

In evaluate

Source string is: inctr

Incrementing pointer

The new value of ctr is 9


The value of ctr is 9

In evaluate

Source string is: inctr

Incrementing pointer

The new value of ctr is 10


The value of ctr is 10

In evaluate

Source string is: inctr

Incrementing pointer

The new value of ctr is 11

.... etc.


So, the pointer gets incremented and the 'Incrementing pointer' is printed.


When I get the bug (always on battery power, occasionally on USB power), my
code prints the following:


The value of ctr is 6

In evaluate

Source string is: inctr

The new value of ctr is 6


The value of ctr is 6

In evaluate

Source string is: inctr

The new value of ctr is 6

etc...


So, evaluate gets called and the source string is correct, but the pointer
isn't incremented and 'Incrementing pointer' is not printed. So it's not
calling my inctr word.


The next two lines in (evaluate) are:


    ['] source-string is source

    ['] interpret catch

but something seems to be going wrong but I just can't figure it out.

Is there any other debug information that I could print out that might hint
at what's going wrong?

Many thanks,

David
------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
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