spinnman.connections.udp_packet_connections package

Module contents

class spinnman.connections.udp_packet_connections.BMPConnection(connection_data: BMPConnectionData)

Bases: UDPConnection, AbstractSCPConnection

A BMP connection which supports queries to the BMP of a SpiNNaker machine.

Parameters:

connection_data (BMPConnectionData) – The description of what to connect to.

property boards: Sequence[int]

The set of boards supported by the BMP.

Return type:

iterable(int)

property chip_x: int

Defined to satisfy the AbstractSCPConnection - always 0 for a BMP.

property chip_y: int

Defined to satisfy the AbstractSCPConnection - always 0 for a BMP.

get_scp_data(scp_request: AbstractSCPRequest) bytes[source]

Returns the data of an SCP request as it would be sent down this connection.

receive_scp_response(timeout: float | None = 1.0) Tuple[SCPResult, int, bytes, int][source]

Receives an SCP response from this connection. Blocks until a message has been received, or a timeout occurs.

Parameters:

timeout (int) – The time in seconds to wait for the message to arrive; if None, will wait forever, or until the connection is closed

Returns:

The SCP result, the sequence number, the data of the response and the offset at which the data starts (i.e., where the SDP header starts).

Return type:

tuple(SCPResult, int, bytes, int)

Raises:
class spinnman.connections.udp_packet_connections.BootConnection(remote_host: str | None = None)

Bases: UDPConnection

A connection to the SpiNNaker board that uses UDP to for booting.

Parameters:

remote_host (str) – The remote host name or IP address to send packets to. If not specified, the socket will be available for listening only, and will throw and exception if used for sending

Raises:

SpinnmanIOException – If there is an error setting up the communication channel

receive_boot_message(timeout: float | None = None) SpinnakerBootMessage[source]

Receives a boot message from this connection. Blocks until a message has been received, or a timeout occurs.

Parameters:

timeout (float) – The time in seconds to wait for the message to arrive; if not specified, will wait forever, or until the connection is closed.

Returns:

a boot message

Return type:

SpinnakerBootMessage

Raises:
send_boot_message(boot_message: SpinnakerBootMessage)[source]

Sends a SpiNNaker boot message using this connection.

Parameters:

boot_message (SpinnakerBootMessage) – The message to be sent

Raises:

SpinnmanIOException – If there is an error sending the message

class spinnman.connections.udp_packet_connections.EIEIOConnection(local_host: str | None = None, local_port: int | None = None, remote_host: str | None = None, remote_port: int | None = None)

Bases: UDPConnection, Listenable[AbstractEIEIOMessage]

A UDP connection for sending and receiving raw EIEIO messages.

Parameters:
  • local_host (str) – The local host name or IP address to bind to. If not specified defaults to bind to all interfaces, unless remote_host is specified, in which case binding is done to the IP address that will be used to send packets

  • local_port (int) – The local port to bind to, between 1025 and 65535. If not specified, defaults to a random unused local port

  • remote_host (str) – The remote host name or IP address to send packets to. If not specified, the socket will be available for listening only, and will throw and exception if used for sending

  • remote_port (int) – The remote port to send packets to. If remote_host is None, this is ignored. If remote_host is specified specified, this must also be specified for the connection to allow sending

Raises:

SpinnmanIOException – If there is an error setting up the communication channel

get_receive_method() Callable[[], AbstractEIEIOMessage][source]

Get the method that receives for this connection.

receive_eieio_message(timeout: float | None = None) AbstractEIEIOMessage[source]

Receives an EIEIO message from this connection. Blocks until a message has been received, or a timeout occurs.

Parameters:

timeout (int) – The time in seconds to wait for the message to arrive; if not specified, will wait forever, or until the connection is closed

Returns:

an EIEIO message

Return type:

AbstractEIEIOMessage

Raises:
send_eieio_message(eieio_message: AbstractEIEIOMessage)[source]

Sends an EIEIO message down this connection.

Parameters:

eieio_message (AbstractEIEIOMessage) – The EIEIO message to be sent

Raises:

SpinnmanIOException – If there is an error sending the message

send_eieio_message_to(eieio_message: AbstractEIEIOMessage, ip_address: str, port: int)[source]
Parameters:
class spinnman.connections.udp_packet_connections.IPAddressesConnection(local_host=None, local_port=54321)

Bases: UDPConnection

A connection that detects any UDP packet that is transmitted by SpiNNaker boards prior to boot.

Parameters:
  • local_host (str) – The local host name or IP address to bind to. If not specified defaults to bind to all interfaces, unless remote_host is specified, in which case binding is done to the IP address that will be used to send packets

  • local_port (int) – The local port to bind to, between 1025 and 65535. If not specified, defaults to a random unused local port

  • remote_host (str) – The remote host name or IP address to send packets to. If not specified, the socket will be available for listening only, and will throw and exception if used for sending

  • remote_port (int) – The remote port to send packets to. If remote_host is None, this is ignored. If remote_host is specified specified, this must also be specified for the connection to allow sending

Raises:

SpinnmanIOException – If there is an error setting up the communication channel

receive_ip_address(timeout: float | None = None) str | None[source]
Parameters:

timeout (float or None) –

Return type:

str or None

class spinnman.connections.udp_packet_connections.SCAMPConnection(chip_x: int = 255, chip_y: int = 255, local_host: str | None = None, local_port: int | None = None, remote_host: str | None = None, remote_port: int | None = None)

Bases: SDPConnection, AbstractSCPConnection

A UDP connection to SCAMP on the board.

Parameters:
  • chip_x (int) – The x-coordinate of the chip on the board with this remote_host

  • chip_y (int) – The y-coordinate of the chip on the board with this remote_host

  • local_host (str) – The optional IP address or host name of the local interface to listen on

  • local_port (int) – The optional local port to listen on

  • remote_host (str) – The optional remote host name or IP address to send messages to. If not specified, sending will not be possible using this connection

  • remote_port (int) – The optional remote port number to send messages to. If not specified, sending will not be possible using this connection

property chip_x: int

The X-coordinate of the chip at which messages sent down this connection will arrive at first.

Return type:

int

property chip_y: int

The Y-coordinate of the chip at which messages sent down this connection will arrive at first.

Return type:

int

get_scp_data(scp_request: AbstractSCPRequest, x: int | None = None, y: int | None = None) bytes[source]

Returns the data of an SCP request as it would be sent down this connection.

Parameters:
  • x (int) – Optional: x-coordinate of where to send to

  • y (int) – Optional: y-coordinate of where to send to

receive_scp_response(timeout: float | None = 1.0) Tuple[SCPResult, int, bytes, int][source]

Receives an SCP response from this connection. Blocks until a message has been received, or a timeout occurs.

Parameters:

timeout (int) – The time in seconds to wait for the message to arrive; if None, will wait forever, or until the connection is closed

Returns:

The SCP result, the sequence number, the data of the response and the offset at which the data starts (i.e., where the SDP header starts).

Return type:

tuple(SCPResult, int, bytes, int)

Raises:
receive_scp_response_with_address(timeout: float = 1.0) Tuple[SCPResult, int, bytes, int, str, int][source]
Parameters:

timeout (float) –

Return type:

tuple(SCPResult, int, bytes, int, str, int)

update_chip_coordinates(x: int, y: int)[source]

Sets the coordinates without checking they are valid.

Parameters:
class spinnman.connections.udp_packet_connections.SDPConnection(chip_x: int, chip_y: int, local_host: str | None = None, local_port: int | None = None, remote_host: str | None = None, remote_port: int | None = None)

Bases: UDPConnection, Listenable[SDPMessage]

A connection that talks SpiNNaker Datagram Protocol.

Parameters:
  • chip_x (int) – The optional x-coordinate of the chip at the remote end of the connection. If not specified, it will not be possible to send SDP messages that require a response with this connection.

  • chip_y (int) – The optional y-coordinate of the chip at the remote end of the connection. If not specified, it will not be possible to send SDP messages that require a response with this connection.

  • local_host (str) – The optional IP address or host name of the local interface to listen on

  • local_port (int) – The optional local port to listen on

  • remote_host (str) – The optional remote host name or IP address to send messages to. If not specified, sending will not be possible using this connection

  • remote_port (int) – The optional remote port number to send messages to. If not specified, sending will not be possible using this connection

get_receive_method() Callable[[], SDPMessage][source]

Get the method that receives for this connection.

receive_sdp_message(timeout: float | None = None) SDPMessage[source]

Receives an SDP message from this connection. Blocks until the message has been received, or a timeout occurs.

Parameters:

timeout (int) – The time in seconds to wait for the message to arrive; if not specified, will wait forever, or until the connection is closed.

Returns:

The received SDP message

Return type:

SDPMessage

Raises:
send_sdp_message(sdp_message: SDPMessage)[source]

Sends an SDP message down this connection.

Parameters:

sdp_message (SDPMessage) – The SDP message to be sent

Raises:

SpinnmanIOException – If there is an error sending the message.

class spinnman.connections.udp_packet_connections.UDPConnection(local_host: str | None = None, local_port: int | None = None, remote_host: str | None = None, remote_port: int | None = None)

Bases: Connection, Listenable[bytes]

A connection that routes messages via UDP to some remote host.

Subclasses of this should be aware that UDP messages may be dropped, reordered, or duplicated, and that there’s no way to tell whether the other end of the connection truly exists except by listening for occasional messages from them. There is also an upper size limit on messages, formally of 64kB, but usually of about 1500 bytes (the typical maximum size of an Ethernet packet); SDP messages have lower maximum lengths.

Parameters:
  • local_host (str) – The local host name or IP address to bind to. If not specified defaults to bind to all interfaces, unless remote_host is specified, in which case binding is done to the IP address that will be used to send packets

  • local_port (int) – The local port to bind to, between 1025 and 65535. If not specified, defaults to a random unused local port

  • remote_host (str) – The remote host name or IP address to send packets to. If not specified, the socket will be available for listening only, and will throw and exception if used for sending

  • remote_port (int) – The remote port to send packets to. If remote_host is None, this is ignored. If remote_host is specified specified, this must also be specified for the connection to allow sending

Raises:

SpinnmanIOException – If there is an error setting up the communication channel

close() None[source]

Closes the connection.

get_receive_method() Callable[[], bytes][source]

Get the method that receives for this connection.

is_connected() bool[source]

Determines if the medium is connected at this point in time.

Returns:

True if the medium is connected, False otherwise

Return type:

bool

Raises:

SpinnmanIOException – If there is an error when determining the connectivity of the medium.

is_ready_to_receive(timeout: float = 0)[source]

Determines if there is an SCP packet to be read without blocking.

Parameters:

timeout (int) – The time to wait before returning if the connection is not ready

Returns:

True if there is an SCP packet to be read

Return type:

bool

property local_ip_address: str

The local IP address to which the connection is bound, as a dotted string, e.g., 0.0.0.0.

Return type:

str

property local_port: int

The number of the local port to which the connection is bound.

Return type:

int

receive(timeout: float | None = None) bytes[source]

Receive data from the connection.

Parameters:

timeout (float) – The timeout in seconds, or None to wait forever

Returns:

The data received as a byte-string

Return type:

bytes

Raises:
receive_with_address(timeout: float | None = None) Tuple[bytes, Tuple[str, int]][source]

Receive data from the connection along with the address where the data was received from.

Parameters:

timeout (float) – The timeout, or None to wait forever

Returns:

A tuple of the data received and a tuple of the (address, port) received from

Return type:

tuple(bytes, tuple(str, int))

Raises:
property remote_ip_address: str | None

The remote IP address to which the connection is connected, or None if not connected remotely.

Return type:

str

property remote_port: int | None

The remote port number to which the connection is connected, or None if not connected remotely.

Return type:

int

send(data: bytes)[source]

Send data down this connection.

Parameters:

data (bytes or bytearray) – The data to be sent

Raises:

SpinnmanIOException – If there is an error sending the data

send_to(data: bytes, address: Tuple[str, int])[source]

Send data down this connection.

Parameters:
  • data (bytes or bytearray) – The data to be sent as a byte-string

  • address (tuple(str,int)) – A tuple of (address, port) to send the data to

Raises:

SpinnmanIOException – If there is an error sending the data

spinnman.connections.udp_packet_connections.update_sdp_header_for_udp_send(sdp_header, source_x, source_y)

Apply defaults to the SDP header for sending over UDP.

Deprecated since version 7.0: Use SDPHeader.update_for_send() instead.

Parameters:
  • sdp_header (SDPHeader) – The SDP header to update

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

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