|
| host |
|
| port |
|
| socket |
|
| connected |
|
|
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']) |
|
def scratch.Scratch.broadcast |
( |
|
self, |
|
|
|
msg |
|
) |
| |
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 | ) |
|
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
errors.
def scratch.Scratch.sensorupdate |
( |
|
self, |
|
|
|
data |
|
) |
| |
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: