User manual

The old way (required for SNAP versions before version 2.2) snappyGen.setHook()
Somewhere aer the roune that you want to be invoked (typically these lines are put at the boom 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 roune.
This method sll works in the current version, but most people find the new way much easier to remember and
use.
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 roune 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 connecons 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 (or even examined) in any way.
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 SNAP node can be either the consumer or the creator of the serial data.
The Switchboard
The flow of data through a SNAP device is configured via the Switchboard. This allows connecons 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. (You may also use the enumeraons
directly in your scripts, without imporng the switchboard.py file.)
0 = DS_NULL
1 = DS_UART0
2 = DS_UART1
3 = DS_TRANSPARENT
4 = DS_STDIO
5 = DS_ERROR
6 = DS_PACKET_SERIAL
7 = DS_AUDIO (ZIC2410 only)
The SNAPpy API for creang Switchboard connecons is:
crossConnect(dataSrc1, dataSrc2) # Cross-connect SNAP data sources (bidirectional)
uniConnect(dst, src) # Data from src goes to dst (unidirectional)
SNAP® Network Operang System 21