Shop OBEX P1 Docs P2 Docs Learn Events
SOFTWARE reset of Javelin - how to reboot? — Parallax Forums

SOFTWARE reset of Javelin - how to reboot?

GregSGregS Posts: 15
edited 2010-07-02 15:31 in General Discussion
Is there any way from Javelin Java (in the program)·of forcing the equivalent of a hardware reset - i.e. a total reset of the hardware and restart of the Java interpreter and my program?

I have an embedded Javelin application·that runs for weeks but then triggers and exception (probably caused by a bug in my software that I cannot trace).· The exception cannot be handled sensibly so I would prefer to "reboot" automatically and continue from scratch (at least until I can find the bug).· In this way I can be assured that all timers, stacks, heaps, VPs etc are in a known condition.· I don't have a hardware watchdog that can force the reset.

Any help would be appreciated.

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2010-06-30 08:18
    There is no software command.

    The easiest way is to connect an I/O pin to the reset pin.
    The I/O pin is normally an input.
    When you want to reboot make the pin a low output and wait forever.

    This makes the javelin restart (and also the I/O pin becomes an input again).

    regards peter
  • GregSGregS Posts: 15
    edited 2010-06-30 08:34
    Thanks Peter

    No free pins unfortunately!· Was hoping for the equivalent of a GOTO 0 or some undocumented method.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2010-06-30 09:07
    If the javelin stops due to an exception, you can catch the exception.
    Somebody said...
    ·The exception cannot be handled sensibly
    You can always simply put a default or most common value in resultvalues
    or as parameters and then continue the program.

    You can also set a main variable that you use to initialize the javelin.

    //static variables
    static boolean restart = true;

    static void main() {
    · while (true) {
    ··· if (restart) {
    ····· //initialize variables here
    ····· restart = false;
    ··· }
    ··· while (!restart) {
    ······ try {
    ········ //mainloopcode
    ······ }
    ······ catch {
    ········ restart = true;
    ······ }
    ··· }
    · }
    }

    As soon as an exception occurs that is not handled somewhere else, the mainloop code will exit
    and reinitialize all variables.

    regards peter
  • GregSGregS Posts: 15
    edited 2010-06-30 11:10
    Thanks again Peter

    I particularly want to reset all Javelin INTERNAL "interpreter" variables (VPs, stack, heap etc.) as the exception concerns too many VPs when I am NOT creating a VP - this points to some other corruption which probably cannot be cured by re-inititializing application variables. I don't trust the state of the Javelin (interpreter and application) at that stage - who knows which HCF instruction (see halt and catch fire) I could have executed by the time the exception is raised?

    Regards
    Greg
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2010-06-30 11:24
    Somebody said...
    I particularly want to reset all Javelin INTERNAL "interpreter" variables
    That can only be done by a hard reset of course.

    Another problem with the setup I proposed is that if variables are newly initialized
    they require again memory without freeing the memory the variables already
    occupied. You can solve that by having a single memorypool object from
    which you allocate variablespace and then you can also reclaim any memory
    upon reinitializing. But this requires a full rewrite of your code.

    If you have an output pin that already at regular times toggles within a specific period,
    then you could use an external watchdog chip that monitors that pin and when
    the toggle does not occur within the specific timepriod, it sends a low pulse
    to the javelin reset pin.

    regards peter
  • GregSGregS Posts: 15
    edited 2010-06-30 12:49
    Thanks Peter

    I'm afraid that an external watchdog is my only option!
  • jmspaggijmspaggi Posts: 629
    edited 2010-06-30 12:52
    http://forums.parallax.com/forums/default.aspx?f=8&m=131628

    [noparse];)[/noparse]

    JM

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Linux? There is worst, but it's more expensive.
  • GregSGregS Posts: 15
    edited 2010-07-01 10:59
    Interesting!

    A chip I use frequently is the PicAxe-08M - a Basic programmable· 8-pin chip (much like Basic Stamp but MUCH cheaper).· Easy to program with a startup delay and then to sense pulses on a input; if the pulses are missing it resets the Javelin, and then goes thru the startup delay/sense again.· Very easy and flexible, I even use the same serial programming cable as I use for the Javelin/Basic Stamps.

    The PixAxe chips are·fantastic for simple applications·- I use them as data concentrators to 1-wire devices and as analogue to digital convertors.· Trouble is they are programmed in a very primitive Basic.· Hardware is cheap and easy, good programming is slow and expensive, something that Parallax and PicAxe seem to not understand with their insistance on Basic and Spin rather than modern, well designed programming languages </end rant>.

    Look at www.picaxe.co.uk.
  • jmspaggijmspaggi Posts: 629
    edited 2010-07-02 12:22
    Hi Gregs,

    I don't really like this option [noparse];)[/noparse] What if the PicAxe crash? Do you have a WatchDog for it?

    That's why I prefer to have a dedicated component for that. Because my controller is used for my solar system, and if it crash for to long, it can overheat quickly.

    So I'm sur the PicAxe can works, but it will depend on the application.

    JM

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Linux? There is worst, but it's more expensive.
  • GregSGregS Posts: 15
    edited 2010-07-02 15:31
    The probability of the PicAxe crashing at the same time as the Javelin goes into an uncontrolled state is VERY small, probably of the same order as the dedicated watchdog chip having been damaged by static during assembly and expiring at the wrong time!· You could always add a dedicated watchdog chip and the PicAxe, with voting, as NASA does; but we are talking about small scale, non-life threatening systems (I hope).

    Another advantage of the PicAxe is that you can program long/flexible/context-sensitive delays for start-up/reprogramming of the Javelin by connecting a PicAxe input to the Attention input of the Javelin·(shooting my mouth off before actually doing it!!!).



    My point (and I am not associated with PicAxe) is that the 08M is a very felixible, cheap and general purpose chip that can be used in multiple, diverse applications.· I live in a third-world country where you cannot easily access a wide variety of special-purpose chips off the shelf.· The PicAxe solves many problems (and they have more complex chips).· However, even in the most advanced countries, simplicity has its benefits (cf Apple and Microsoft software and products) </end-end-rant>

    I'll keep you updated to my progress.
Sign In or Register to comment.