Shop OBEX P1 Docs P2 Docs Learn Events
FropForth 5.5 -- automatically execute a word on powering up the Propeller — Parallax Forums

FropForth 5.5 -- automatically execute a word on powering up the Propeller

LoopyBytelooseLoopyByteloose Posts: 12,537
edited 2013-05-15 09:47 in Propeller 1
Hi all,
I thought this was an established option in PropForth 5.0 and beyond, but I can't really find anything that seems as if it will do the trick.

What I am doing is writing an application that will be triggered by one word and run endlessly in an infinite loop until power is removed.

I'd like to have PropForth automatically start the program without outside input after it is powered up.

Do I have to modify DevKernel.spin to do this, or is there already an established feature that will create a word that will automatically run?

Comments

  • prof_brainoprof_braino Posts: 4,313
    edited 2013-05-14 20:36
    onboot is the word you want, I think. The most recent definition of onboot is called on boot, and onreset for individual cogs is called when a cog is reset.
    : onboot 
                  onboot \ so is does whatever it used to do, if it was doing something
                  loopyword  \ this is really all you need if yo don;t need the previously defined behavior
    ;
    
  • prof_brainoprof_braino Posts: 4,313
    edited 2013-05-14 21:01
    Then again maybe not. I just tried onboot and it didn't do what I thought it would....

    Sorry,
    onboot reads and executes boot.f if it exists.
    onreset give a reset message.

    I had this someplace, I just have to dig through some stuff to find it...
  • prof_brainoprof_braino Posts: 4,313
    edited 2013-05-14 21:26
    I have this page, which I though worked correctly at the time.

    http://code.google.com/p/propforth/wiki/BootAnApplication

    Please give that a look. I used that with the quickstart touch demo from caskaz, but it looks different than the onboot and on reset in propforth.htm. Its late here, and I might be confusing myself
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-05-15 01:50
    Hi and thanks,
    I will look at what you have provided.

    For the sake of clarity we can stick with 'loopyword' being the actual target word I want to execute, you seem to have used the alternative called 'onboot'. Since this will go into an infinite loop, there is no need to recover the to a Forth prompt, if that is yet another technical issue that might require more code.

    The word 'loopyword' is a character string, but has an associated dictionary location identified as an address. At this point, I'd just like to have 'loopyword' setup to always execute on power up, regardless of the validity of the word's internal structure.

    Could I just modify DevKernel.spin to always execute 'loopyword' upon starting, and then later either redefine or define loopyword to what I need?

    In the first case, 'loopyword' could be included with the task that just outputs a message that it exists and is ready to redefine, Then I could later redefine as required

    In the second case, with no 'loopyword' deifinition included in the starting lexicon-- the initiation process would just generate an error that 'loopyword' could not be located. Then I could for reboot add 'loopyword' to the existing dictionary via a 'saveforth'.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-05-15 07:00
    It looks as if something as simple as the following will work.

    : booter onreset loopyword ; /create a call to loopyword when board resets

    And then a 'saveforth' to write to EEPROM.

    I will test this and let you know.


    ~~~~~~~~~~~~~~~
    I am a bit wary of what 'onboot' is supposed to do. It seems to be just another way. The documentation is a bit sparse on both of these.

    And though, there are called to load a boot.f file in some cases, I can't seem to locate the actual boot.f file to examine it.
  • prof_brainoprof_braino Posts: 4,313
    edited 2013-05-15 07:42
    Previously, I thought there was a word that is automatically called when the kernel starts, and by default it just calls the interpreter 'quit' loop.

    This was simillar to the way the 'turnkey' works in other forths.

    I understood ONBOOT to be the word call on power cycle and reboot, and onreset when a cog is reset. ONRESET0 through ONRESET7 would be the words called for the intdividual cogs. But looking at propforth.htm, it appears this might be ddifferent from how I thought I ubnderstood it.

    I know this ability exists, its always in every forth I've seen, and it has been in propforth in previous versions. I must have missed ONBOOT changing so now it call boot.f

    If you can't get it to work I will ask Sal next Sunday.

    EDIT - boot.f is a file in the your file system ( for the EEProm kernel or SD kernel) and is that same as any other forth file, except this one is called automaticially. Its just a text find that is read by the interpreter, and can contain new definitions, and/or sequences of sero or more forth words to execute.

    Maybe in the NON-file system kerrnel, onboot is still called, and just executes instead of calling boot.f. We would have to update the docs.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-05-15 09:47
    I had suspected that boot.f was part of the EEPROM or SD versions of PropForth, but I was trying to find a solution without these.

    If needed, I can go with an EEPROM solution as the project is on a 64K EEPROM board, a Propeller QuickStart.

    If I get something working well without the EEPROM or the SDcard, I will let you know.
Sign In or Register to comment.