User manual

SNAP Hooks
There are a number of events in the system that you might like to trigger some SNAPpy funcon “handler.”
When defining your SNAPpy scripts, there is a way to associate funcons with these external events. That is
done by specifying a “HOOK” idenfier for the funcon. The following HOOKs are defined:
Hook Name When Invoked Parameters Sample Signature
HOOK_STARTUP
Called on device
bootup
HOOK_STARTUP passes no
parameters.
@setHook(HOOK_STARTUP)
def onBoot():
pass
HOOK_GPIN
Called on transion
of a monitored
hardware pin
pinNum The pin number
of the pin that has
transioned.
isSet A Boolean value
indicang whether the pin
is set.
@setHook(HOOK_GPIN)
def pinChg(pinNum,
isSet):
pass
HOOK_1MS
Called every
millisecond
ck A rolling 16-bit
integer incremented every
millisecond indicang the
current count on the
internal clock. The same
counter is used for all four
ming hooks.
@setHook(HOOK_1MS)
def doEvery1ms(tick):
pass
HOOK_10MS
Called every 10
milliseconds
ck A rolling 16-bit
integer incremented every
millisecond indicang the
current count on the
internal clock. The same
counter is used for all four
ming hooks.
@setHook(HOOK_10MS)
def doEvery10ms(tick):
pass
HOOK_100MS
Called every 100
milliseconds
ck A rolling 16-bit
integer incremented every
millisecond indicang the
current count on the
internal clock. The same
counter is used for all four
ming hooks.
@setHook(HOOK_100MS)
def doEvery100ms(tick):
pass
HOOK_1S
Called every second
ck A rolling 16-bit
integer incremented every
millisecond indicang the
@setHook(HOOK_1S)
def doEverySec(tick):
SNAP® Network Operang System 19