Specifications
Hook Name When
Invoked
Parameters Sample Signature
HOOK_100MS
Called every
100
milliseconds
• tick – A rolling 16-bit integer
incremented every
millisecond indicating the
current count on the internal
clock. The same counter is
used for all four timing hooks.
@setHook(HOOK_100MS)
def doEvery100ms(tick):
pass
HOOK_1S
Called every
second
• tick – A rolling 16-bit integer
incremented every
millisecond indicating the
current count on the internal
clock. The same counter is
used for all four timing hooks.
@setHook(HOOK_1S)
def doEverySec(tick):
pass
HOOK_STDIN
Called when
“user input”
data is
received
• data – A data buffer
containing one or more
received characters.
@setHook(HOOK_STDIN)
def getInput(data):
pass
HOOK_STDOUT
Called when
“user
output” data
is sent
HOOK_STDOUT passes no
parameters.
@setHook(HOOK_STDOUT)
def printed():
pass
HOOK_RPC_SENT
Called when
the buffer
for an
outgoing
RPC call is
cleared
• bufRef – an integer reference
to the packet that the RPC call
attempted to send. This
integer will correspond to the
value returned from
getInfo(9) when called
immediately after an RPC call
is made. The receipt of a
value from
HOOK_RPC_SENT does not
necessarily indicate that the
packet was sent and received
successfully. It is an
indication that SNAP has
completed processing the
packet.
@setHook(HOOK_RPC_SENT)
def rpcDone(bufRef):
pass
NOTE – Time-triggered event handlers must run quickly, finishing well before the next time period
occurs. To ensure this, keep your timer handlers concise. There is no guarantee that a timing handler
will run precisely on schedule. If a SNAPpy function is running when the time hook occurs, the
running code will not be interrupted to run the timer hook code.
Within a SNAPpy script, there are two methods for specifying the correct handler for a given HOOK
event:
Page 26 of 202 SNAP Reference Manual Document Number 600-0007K