hardware_messages Module

This modue contains all the messages taht are received.

AYABInterface.communication.hardware_messages.read_message_type(file)[source]

Read the message type from a file.

class AYABInterface.communication.hardware_messages.StateIndication(file, communication)[source]

Bases: AYABInterface.communication.hardware_messages.FixedSizeMessage

This message shows the state of the controller.

MESSAGE_ID = 132

The first byte that indicates this message

carriage

The carriage which is reported.

Return type:AYABInterface.communication.carriages.Carriage
Returns:the carriage with information about its position
current_needle

The current needle position.

Return type:int
is_ready_to_knit()[source]

Whether this message indicates that the controller can knit now.

is_state_indication()[source]

Whether this is a InformationConfirmation message.

Return type:bool
Returns:True
is_valid()[source]

Whether this messages matches the specification.

left_hall_sensor_value

The value of the left hall sensor.

Return type:int
received_by(visitor)[source]

Call visitor.receive_state_indication.

right_hall_sensor_value

The value of the left hall sensor.

Return type:int
class AYABInterface.communication.hardware_messages.LineRequest(file, communication)[source]

Bases: AYABInterface.communication.hardware_messages.FixedSizeMessage

The controller requests a line.

MESSAGE_ID = 130

The first byte that indicates this message

is_line_request()[source]

Whether this is a LineRequest message.

Return type:bool
Returns:True
line_number

The line number that was requested.

received_by(visitor)[source]

Call visitor.receive_line_request.

class AYABInterface.communication.hardware_messages.TestConfirmation(file, communication)[source]

Bases: AYABInterface.communication.hardware_messages.SuccessConfirmation

This message is sent at/when

MESSAGE_ID = 196

The first byte that indicates this message

is_test_confirmation()[source]

Whether this is a TestConfirmation message.

Return type:bool
Returns:True
received_by(visitor)[source]

Call visitor.test_information_confirmation.

class AYABInterface.communication.hardware_messages.InformationConfirmation(file, communication)[source]

Bases: AYABInterface.communication.hardware_messages.FixedSizeMessage

This message is the answer in the initial handshake.

A InformationRequest requests this message from the controller to start the initial handshake.

MESSAGE_ID = 195

The first byte that indicates this message

api_version

The API version of the controller.

Return type:int
api_version_is_supported()[source]

Whether the communication object supports this API version.

Return type:bool
firmware_version

The firmware version of the controller.

Return type:FirmwareVersion
minor_version = int()
mayor_version = int()

assert message.firmware_version == (mayor_version, minor_version)
assert message.firmware_version.major == mayor_version
assert message.firmware_version.minor == minor_version
is_information_confirmation()[source]

Whether this is a InformationConfirmation message.

Return type:bool
Returns:True
received_by(visitor)[source]

Call visitor.receive_information_confirmation.

class AYABInterface.communication.hardware_messages.Debug(file, communication)[source]

Bases: AYABInterface.communication.hardware_messages.Message

This message contains debug output from the controller.

bytes

The debug message as bytes.

Return type:bytes
Returns:the debug message as bytes without the b'\r\n' at the end
is_debug()[source]

Whether this is a Debug message.

Return type:bool
Returns:False
received_by(visitor)[source]

Call visitor.receive_debug.

class AYABInterface.communication.hardware_messages.StartConfirmation(file, communication)[source]

Bases: AYABInterface.communication.hardware_messages.SuccessConfirmation

This marks the success or failure of a reqStart message.

MESSAGE_ID = 193

The first byte that indicates this message

is_start_confirmation()[source]

Whether this is a StartConfirmation message.

Return type:bool
Returns:True
received_by(visitor)[source]

Call visitor.receive_state_confirmation.

class AYABInterface.communication.hardware_messages.SuccessConfirmation(file, communication)[source]

Bases: AYABInterface.communication.hardware_messages.FixedSizeMessage

Base class for massages of success and failure.

is_success()[source]

Whether the configuration was successful.

Return type:bool
is_valid()[source]

Whether this message is valid.

class AYABInterface.communication.hardware_messages.UnknownMessage(file, communication)[source]

Bases: AYABInterface.communication.hardware_messages.FixedSizeMessage

This is a special message for unknown message types.

is_unknown()[source]

Whether this is a StateIndication message.

Return type:bool
Returns:True
is_valid()[source]

Whether the message is valid.

Return type:bool
Returns:False
received_by(visitor)[source]

Call visitor.receive_unkown.

class AYABInterface.communication.hardware_messages.Message(file, communication)[source]

Bases: object

This is the base class for messages that are received.

__init__(file, communication)[source]

Create a new Message.

__repr__()[source]

This object as string.

Return type:str
__weakref__

list of weak references to the object (if defined)

is_connection_closed()[source]

Whether this is a ConnectionClosed message.

Return type:bool
Returns:False
is_debug()[source]

Whether this is a Debug message.

Return type:bool
Returns:False
is_from_controller()[source]

Whether this message is sent by the controller.

Return type:bool
Returns:True
is_from_host()[source]

Whether this message is sent by the host.

Return type:bool
Returns:False
is_information_confirmation()[source]

Whether this is a InformationConfirmation message.

Return type:bool
Returns:False
is_line_request()[source]

Whether this is a LineRequest message.

Return type:bool
Returns:False
is_start_confirmation()[source]

Whether this is a StartConfirmation message.

Return type:bool
Returns:False
is_state_indication()[source]

Whether this is a StateIndication message.

Return type:bool
Returns:False
is_test_confirmation()[source]

Whether this is a TestConfirmation message.

Return type:bool
Returns:False
is_unknown()[source]

Whether this is a StateIndication message.

Return type:bool
Returns:False
is_valid()[source]

Whether the message is valid.

Return type:bool
Returns:True
wants_to_answer()[source]

Whether this message produces and answer message.

Return type:bool
Returns:False
class AYABInterface.communication.hardware_messages.ConnectionClosed(file, communication)[source]

Bases: AYABInterface.communication.hardware_messages.Message

This message is notified about when the connection is closed.

is_connection_closed()[source]

Whether this is a ConnectionClosed message.

Return type:bool
Returns:True
received_by(visitor)[source]

Call visitor.receive_connection_closed.

class AYABInterface.communication.hardware_messages.FirmwareVersion(major, minor)

Bases: tuple

__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

__getstate__()

Exclude the OrderedDict from pickling

static __new__(_cls, major, minor)

Create new instance of FirmwareVersion(major, minor)

__repr__()

Return a nicely formatted representation string

major

Alias for field number 0

minor

Alias for field number 1

class AYABInterface.communication.hardware_messages.FixedSizeMessage(file, communication)[source]

Bases: AYABInterface.communication.hardware_messages.Message

This is a message of fixed size.

__init__(file, communication)[source]

Create a new Message.

read_end_of_message()[source]

Read the b”rn” at the end of the message.