spinnman.messages.sdp package

Module contents

class spinnman.messages.sdp.SDPFlag(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

SDPFlag for the message.

REPLY_EXPECTED = 135
REPLY_EXPECTED_NO_P2P = 167
REPLY_NOT_EXPECTED = 7
REPLY_NOT_EXPECTED_NO_P2P = 39
class spinnman.messages.sdp.SDPHeader(flags: SDPFlag, tag: int | None = None, destination_port: int = 0, destination_cpu: int = 0, destination_chip_x: int = 0, destination_chip_y: int = 0, source_port: int | None = None, source_cpu: int | None = None, source_chip_x: int | None = None, source_chip_y: int | None = None)

Bases: object

Represents the header of an SDP message. Each optional parameter in the constructor can be set to a value other than None once, after which it is immutable. It is an error to set a parameter that is not currently None.

Parameters:
  • flags (SDPFlag) – Any flags for the packet

  • tag (int) – The IP tag of the packet between 0 and 255, or None if it is to be set later

  • destination_port (int) – The destination port of the packet between 0 and 7

  • destination_cpu (int) – The destination processor ID within the chip between 0 and 31

  • destination_chip_x (int) – The x-coordinate of the destination chip between 0 and 255

  • destination_chip_y (int) – The y-coordinate of the destination chip between 0 and 255

  • source_port (int) – The source port of the packet between 0 and 7, or None if it is to be set later

  • source_cpu (int) – The source processor ID within the chip between 0 and 31, or None if it is to be set later

  • source_chip_x (int) – The x-coordinate of the source chip between 0 and 255, or None if it is to be set later

  • source_chip_y (int) – The y-coordinate of the source chip between 0 and 255, or None if it is to be set later

property bytestring: bytes

The header as a byte-string.

Return type:

bytes

property destination_chip_x: int

The x-coordinate of the destination chip of the packet, between 0 and 255 (settable).

Return type:

int

property destination_chip_y: int

The y-coordinate of the destination chip of the packet, between 0 and 255 (settable).

Return type:

int

property destination_cpu: int

The core on the destination chip, between 0 and 31 (settable).

Return type:

int

property destination_port: int

The destination SDP port of the packet, between 0 and 7 (settable).

Return type:

int

property flags: SDPFlag

The flags of the packet (settable).

Return type:

SDPFlag

static from_bytestring(data: bytes, offset: int)[source]

Read the header from a byte-string.

Parameters:
  • data (bytes or bytearray) – The byte-string to read the header from

  • offset (int) – The offset into the data from which to start reading

get_physical_cpu_id() str[source]

A String describing the physical core of the destination.

Return type:

str

property source_chip_x: int

The x-coordinate of the source chip of the packet, between 0 and 255 (settable).

Return type:

int

property source_chip_y: int

The y-coordinate of the source chip of the packet, between 0 and 255 (settable).

Return type:

int

property source_cpu: int

The core on the source chip, between 0 and 31 (settable).

Return type:

int

property source_port: int

The source SDP port of the packet, between 0 and 7 (settable).

Return type:

int

property tag: int

The tag of the packet, between 0 and 255 (settable).

Return type:

int

update_for_send(source_x: int, source_y: int)[source]

Apply defaults to the header for sending over UDP.

Parameters:
  • source_x (int) – Where the packet is deemed to originate: X coordinate

  • source_y (int) – Where the packet is deemed to originate: Y coordinate

class spinnman.messages.sdp.SDPMessage(sdp_header: SDPHeader, data: bytes | None = None, offset: int = 0)

Bases: object

Wraps up an SDP message with a header and optional data.

Parameters:
  • sdp_header (SDPHeader) – The header of the message

  • data (bytes or bytearray or None) – The data of the SDP packet, or None if no data

  • offset (int) – The offset where the valid data starts

property bytestring: bytes

The byte-string of the message.

Return type:

bytes

property data: bytes | None

The data in the packet.

Return type:

bytes or bytearray or None

static from_bytestring(data: bytes, offset: int) SDPMessage[source]
Parameters:
Return type:

SDPMessage

property offset: int

The offset where the valid data starts.

Return type:

int

property sdp_header: SDPHeader

The header of the packet.

Return type:

SDPHeader