networking

Classes for network communication.

There are two general types of network objects -

  • autopilot.networking.Station and its children are independent processes that should only be instantiated once

    per piece of hardware. They are used to distribute messages between Net_Node s, forward messages up the networking tree, and responding to messages that don’t need any input from the Pilot or Terminal.

  • Net_Node is a pop-in networking class that can be given to any other object that

    wants to send or receive messages.

The Message object is used to serialize and pass messages. When sent, messages are JSON serialized (with some special magic to compress/encode numpy arrays) and sent as zmq multipart messages.

Each serialized message, when sent, can have n frames of the format:

[hop_0, hop_1, ... hop_n, final_recipient, serialized_message]

Or, messages can have multiple “hops” (a typical message will have one ‘hop’ specified by the to field), the second to last frame is always the final intended recipient, and the final frame is the serialized message. Note that the to field of a Message object will always be the final recipient even if a list is passed for to when sending. This lets Station objects efficiently forward messages without deserializing them at every hop.

Functions:

serialize_array(array)

Pack an array with blosc.pack_array() and serialize with base64.b64encode()

serialize_array(array)[source]

Pack an array with blosc.pack_array() and serialize with base64.b64encode()

Parameters

array (numpy.ndarray) – Array to serialize

Returns

{‘NUMPY_ARRAY’: base-64 encoded, blosc-compressed array.}

Return type

dict