Specifications

global sleepCountDown
if sleepCountDown > 0:
if sleepCountDown < 100: # timebase is 100 ms
sleepCountDown = 0
sleep(mode, duration)
else:
sleepCountDown -= 100
Remember nodes do not have a lot of RAM
SNAPpy scripts should avoid generating a flood of text output all at once (there will be no where to
buffer the output). Instead, generate the composite output in small pieces (for example, one line at a
time), triggering the process with the HOOK_STDOUT event.
If a script generates too much output at once, the excess text will be truncated.
Remember SNAPpy Numbers Are Integers
2/3 = 0 in SNAPpy. As in all fixed point systems, you can work around this by “scaling” your internal
calculations up by a factor of 10, 100, etc. You then scale your final result down before presenting it to
the user.
Remember SNAPpy Integers are Signed
SNAPpy integers are 16-bit numbers, and have a numeric range of -32768 to +32767.
Be careful that any intermediate math computations do not exceed this range, as the resulting overflow
value will be incorrect.
Remember SNAPpy Integers have a Sign Bit
Another side-effect of SNAPpy integers being signed – negative numbers shifted right are still
negative (the sign bit is preserved).
You might expect 0x8000 >> 1 to be 0x4000 but really it is 0xC000. You can use bitwise and-ing
to get the desired effect if you need it.
X = X >> 1
X = X & 0x7FFF
Pay Attention to Script Output
Any SNAPpy script errors (see section 4) that occur can be printed to the previously configured
STDOUT destination, such as serial port 1. If your script is not behaving as expected, be sure and
check the output for any errors that may be reported.
If the node having the errors is a remote one (you cannot see its script output), remember that you can
invoke the “Intercept STDOUT” action from the Node Info tab for that node. The error messages will
then appear in the Portal event log, depending on the preferences specified in Portal.
SNAP Reference Manual Document Number 600-0007K Page 89 of 202