Specifications
The new way – @setHook()
Immediately before the routine that you want to be invoked, put a
@setHook(HOOK_xxx)
where HOOK_xxx is one of the predefined HOOK codes given previously. This method is used in the
samples provided above.
The old way (before version 2.2) – snappyGen.setHook()
This method still works in the current version, but most people find the new way much easier to
remember and use.
Somewhere after the routine that you want to be invoked (typically these lines are put at the
bottom of the SNAPpy source file), put a line like
snappyGen.setHook(SnapConstants.HOOK_XXX, eventHandlerXXX)
where eventHandlerXXX should be replaced with the real name of your intended handling routine.
Be sure to “hook” the correct event. For example, HOOK_STDIN lets SNAP Nodes process incoming
serial data. HOOK_STDOUT lets SNAP Nodes know when a previous “print” statement has been
completed.
Also, be sure that the routine you are using for your event processing accepts the appropriate
parameters, whether it actually uses them or not.
Transparent Data (Wireless Serial Port)
SNAP supports efficient, reliable bridging of serial data across a wireless mesh. Data connections
using the transparent mode can exist alongside RPC-based messaging.
Scripted Serial I/O (SNAPpy STDIO)
SNAP’s transparent mode takes data from one interface and forwards it to another interface (possibly
the radio), but the data is not altered in any way (or even examined).
SNAPpy scripts can also interact directly with the serial ports, allowing custom serial protocols to be
implemented. For example, one of the included sample scripts shows how to interface serially to an
external GPS unit.
The Switchboard
The flow of data through a SNAP device is configured via the Switchboard. This allows connections
to be established between sources and sinks of data in the device. The following Data Sources/Sinks
are defined in the file switchboard.py, which can be imported by other SNAPpy scripts:
SNAP Reference Manual Document Number 600-0007K Page 27 of 202