File /etc/rc.local
Edit the file with this command (Inserted at the end of the file just BEFORE exit 0
)
sudo nano /etc/rc.local
#WATCHDOG echo "12" > /sys/class/gpio/export & sleep 2 echo out > /sys/class/gpio/gpio12/direction
This code will be used to test the functionality of the watchdog installed on the SVXLink Card.
As the boot time is greater than 10 seconds, it is recommended to set the detection time (timeout) at its maximum value. As showed in the table below from the datasheet of the MAX6369, the 3 jumpers SET0, SET1 and SET2 are set (weld the three pairs of squares)
The following code will allow to generate on the input of the watchdog a bistable state with a 2 seconds period.
#!/usr/bin/python import time from RPi import GPIO GPIO.setmode(GPIO.BOARD) GPIO.setup(32, GPIO.OUT) while True: inputval1 = GPIO.output(32, False) time.sleep(1) inputval1 = GPIO.output(32, True) time.sleep(1)
While the program is launched with this command
sudo python test-watchdog.py
With a second terminal connected to the Raspberry Pi, we verify the commutation of the output with the following bash command (console)
while true; gpio read 26; done
The validation-jumper must be set up (installed) to allow the start up of the watchdog.
Now with a CTRL-C, we are executing a crash simulation of the program test-watchdog.py by stopping its execution. After that, the watchdog is going to restart the Raspberry Pi. It's done after 180 to 300 seconds. At the end of the restart the terminals connections need to be restarted.