Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => iMX233 => Topic started by: flavigny on October 11, 2012, 01:43:51 PM

Title: How I add a (soft) external watchdog against my application
Post by: flavigny on October 11, 2012, 01:43:51 PM
I have another post pending about howto interface C with the internal watchdog of iMX233.
Here is how I bypass it:

I wrote a script derived from legacy blink_led  (blink_and_kick):
#set led according to parameter 0:off 1:on
echo out> /sys/class/gpio/gpio65/direction
echo $1 > /sys/class/gpio/gpio65/value
‎#kick the dog
echo a > /dev/watchdog

in my C code, I add a function:
int awake(int appel,int delay) {
   static time_t timeprevious;
   static int led=1;
   // printf ("called by: #%d, wait %d\"\r\n",appel,delay);
   time_t timenow;
   int count=delay;
   while (count>=0) {
      if (delay==0 || timenow != timeprevious) {
          // reverse the led state
          // build command
          sprintf (cmdled,"/home/root/blink_and_kick %d",led);
          // keep time
          // wait 1"
          if (delay>0) sleep (1);
   return 0;

So if the function awake is not called during a laps (probably hearbeat 19", set at boot-time) I obtain reboot.