Specifications

def startupEvent():
"""System startup code, invoked automatically (do not call this manually)"""
global otherNodeAddr
initUart(1, 9600) # <= put your desired baudrate here!
flowControl(1, False) # <= set flow control to True or False as needed
crossConnect(DS_UART1, DS_TRANSPARENT)
otherNodeAddr = loadNvParam(OTHER_NODE_ADDR_ID)
ucastSerial(otherNodeAddr)
def setOtherNode(address):
"""Call this at least once, and specify the OTHER node's address"""
global otherNodeAddr
otherNodeAddr = address
saveNvParam(OTHER_NODE_ADDR_ID, otherNodeAddr)
ucastSerial(otherNodeAddr)
This script shows how to use the saveNvParam() and loadNvParam() functions to have units
remember important configuration settings. The script could be further enhanced to treat the baud rate
and hardware handshaking options as User NV Parameters as well.
You can read more about NV Parameters in section 7 and section 8.
Code Density
When you upload a SNAPpy script to a node, you are not sending the raw text of the SNAPpy script to
the node.
Instead the SNAPpy source code is compiled into byte-code for a custom Virtual Machine (the
SNAPpy VM), and this byte-code and data (SNAPpy “Image”) is sent instead.
We have not performed an exhaustive analysis, but a quick check of two typical example scripts
(ZicCycle.py and Zic2410i2cTests.py) showed code densities of 11.625 and 13.138 bytes/line of code.
So, a conservative estimate of SNAPpy code density is 10-15 bytes per line of SNAPpy code.
Simple code will have a higher density, scripts that include a lot of data (for example, text) will be
lower.
For example:
def hi():
print "Hi”
takes 35 bytes but
def hi():
print "Hello everyone, I know my ABCs! - ABCDEFGHIJKLMNOPQRSTUVWXYZ"
takes 91 bytes.
Keeping text messages and function names short will help conserve SNAPpy script space.
SNAP Reference Manual Document Number 600-0007K Page 33 of 202