PiStorms  4.012
PiStorms Library Reference by mindsensors.com
 All Classes Namespaces Files Functions Variables
scratch.Scratch Class Reference
Inheritance diagram for scratch.Scratch:

Public Member Functions

def __init__
def __repr__
def connect
def disconnect
def sensorupdate
def broadcast
def receive

Public Attributes


Static Public Attributes

int prefix_len = 4
tuple broadcast_prefix_len = prefix_len+len('broadcast ')
tuple sensorupdate_prefix_len = prefix_len+len('sensor-update ')
tuple msg_types = set(['broadcast', 'sensor-update'])

Member Function Documentation

def scratch.Scratch.broadcast (   self,
Broadcasts msg to Scratch. msg can be a single message or an iterable 
(list, tuple, set, generator, etc.) of messages.
def scratch.Scratch.connect (   self)
Connects to Scratch.
def scratch.Scratch.disconnect (   self)
Closes connection to Scratch
def scratch.Scratch.receive (   self)
Receives broadcasts and sensor updates from Scratch. Returns a tuple
with the first element as the message type and the second element 
as the message payload. broadcast messages have a string as payload, 
and the sensor-update messages have a dict as payload. Returns None if 
message received could not be parsed. Raises exceptions on connection
def scratch.Scratch.sensorupdate (   self,
Given a dict of sensors and values, updates those sensors with the 
values in Scratch.

The documentation for this class was generated from the following file: