Specifications
For example, node A could invoke the following on node B:
callback('showResult', 'readAdc', 0)
Node “B” would invoke readAdc(0), and then remotely invoke showResult(the-actual-ADC-reading-
goes-here) on node A.
The callback() function is most commonly used with the rpc() function. For example:
rpc(nodeB, 'callback', 'showResult', 'readAdc', 0)
Basically callback() allows you to ask one node to do something, and then tell you how it turned out.
This function normally returns True. It returns False only if it was unable to attempt the Remote
Procedure Call (for example, if the node is low on memory).
callout(nodeAddress, callback, remoteFunction, remoteFunctionArgs…)
To understand this function, you should first be comfortable with using the rpc() and callback() built-
ins.
Function callout() is similar to function callback(), but instead of the final result being reported back to
the originating node, you explicitly provide the address of the target node.
Parameter nodeAddress specifies the SNAP Address of the target node that is to receive the final
(result) function call.
Parameter callback specifies a function to invoke on the target node with the return value of the
remote function. For example, imagine having a function like the following in SNAP Node C.
def showResult(obj):
print str(obj)
Invoking callout(nodeC, 'showResult', ...) will cause function showResult() to get
called with the live data from the remote node.
Parameter remoteFunction specifies a function to invoke on the remote node, for example readAdc.
If the remote function takes any parameters, then the remoteFunctionArgs parameter of the callout()
function is where you put them.
For example, node A could invoke the following on node B, which would automatically invoke node
C:
callout(nodeC, 'showResult', 'readAdc', 0)
Page 44 of 202 SNAP Reference Manual Document Number 600-0007K