EasyManua.ls Logo

Digi ConnectPort X2e ZB - Watchdog

Digi ConnectPort X2e ZB
72 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Sample programs
63
Watchdog
The watchdog feature, provided through the watchdog module, exists as a safeguard. If there are
critical operations that “must” happen periodically, or else the system will be irretrievably broken,
an application can request that a “watchdog” be established. If the application threads do not
service their watchdog within the promised interval, the entire system reboots. These software
watchdogs can have their intervals changed, if necessary, and can be deleted. Clearly, use of such a
software watchdog exists as a measure of last resort. Appropriate error detection and handling with
Python scripts is certainly recommended.
The following sample program demonstrates the watchdog feature.
import watchdog (1)
import time
w=watchdog.Watchdog('test',20) (2)
for x in xrange(1,6): (3)
print "Step ", x (4)
time.sleep(10.0) (5)
w.heartbeat() (6)
print "Step just before the end..." (7)
time.sleep(60.0) (8)
print "Step after the end." (9)
Program notes
1 The watchdog module includes the Watchdog class needed by the program.
2 Create a watchdog object named “test” that will expire in 20 seconds.
3 Loop five times (1-5).
4 Indicate our iteration...
5 ... sleeping less than the timeout on each iteration, but more time than the timeout in total.
6 Reset the watchdog timer to 20 seconds each iteration, allowing all of the loops to complete.
7 Indicate that small loops are complete.
8 Sleep for an interval much longer than the timeout.
9 This print statement should never be executed, as the system should have rebooted due to
the watchdog timeout expiration.

Table of Contents

Other manuals for Digi ConnectPort X2e ZB

Related product manuals