Specifications
5. SNAPpy Application Development
This section outlines some of the basic issues to be considered when developing SNAP based
applications.
Event-Driven Programming
Applications in SNAPpy often have several activities going on concurrently. How is this possible,
with only one CPU on the SNAP Engine? In SNAPpy, concurrency is achieved through event-driven
programming. This means that most SNAPpy functions run quickly to completion, and never “block”
or “loop” waiting for something. External events will trigger SNAPpy functions.
SNAP Hooks
There are a number of events in the system that you might like to trigger some SNAPpy function
“handler.” When defining your SNAPpy scripts, there is a way to associate functions with these
external events. That is done by specifying a “HOOK” identifier for the function. 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
transition of
a monitored
hardware
pin
• pinNum – The pin number of
the pin that has transitioned.
1
• isSet – A Boolean value
indicating whether the pin is
set.
@setHook(HOOK_GPIN)
def pinChg(pinNum, isSet):
pass
HOOK_1MS
Called every
millisecond
• 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_1MS)
def doEvery1ms(tick):
pass
HOOK_10MS
Called every
10
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_10MS)
def doEvery10ms(tick):
pass
1
Note that the pin number refers to the numbering scheme relevant for the particular platform, and the number provided
may not be the number that matches the pin placement on the SNAP Engine or module you are using. Refer to Section 10
for the hardware details for your particular platform for specifics. If you are working with a SNAP Engine (RF100, RF200,
RF300, SM700, or ZICM2410-based engine), you can import the platforms file to provide mappings of platform-specific
pins to GPIO numbers that match the footprint of the SNAP Engine.
SNAP Reference Manual Document Number 600-0007K Page 25 of 202