diff --git a/spinnman/connections/abstract_classes/abstract_scp_connection.py b/spinnman/connections/abstract_classes/abstract_scp_connection.py index 3168f47d7..8b05f40a4 100644 --- a/spinnman/connections/abstract_classes/abstract_scp_connection.py +++ b/spinnman/connections/abstract_classes/abstract_scp_connection.py @@ -66,29 +66,6 @@ def get_scp_data(self, scp_request: AbstractSCPRequest) -> bytes: """ raise NotImplementedError - @abstractmethod - def send_scp_request(self, scp_request: AbstractSCPRequest): - """ - Sends an SCP request down this connection. - - Messages must have the following properties: - - * source_port is `None` or 7 - * source_cpu is `None` or 31 - * source_chip_x is `None` or 0 - * source_chip_y is `None` or 0 - - tag in the message is optional; if not set, the default set in the - constructor will be used. - sequence in the message is optional; if not set, (sequence number - last assigned + 1) % 65536 will be used - - :param AbstractSCPRequest scp_request: message packet to send - :raise SpinnmanIOException: - If there is an error sending the message - """ - raise NotImplementedError - @property @abstractmethod def chip_x(self) -> int: diff --git a/spinnman/connections/udp_packet_connections/bmp_connection.py b/spinnman/connections/udp_packet_connections/bmp_connection.py index b85a4c176..4b123b85b 100644 --- a/spinnman/connections/udp_packet_connections/bmp_connection.py +++ b/spinnman/connections/udp_packet_connections/bmp_connection.py @@ -83,10 +83,6 @@ def receive_scp_response(self, timeout: Optional[float] = 1.0) -> Tuple[ result, sequence = _TWO_SHORTS.unpack_from(data, 10) return SCPResult(result), sequence, data, 2 - @overrides(AbstractSCPConnection.send_scp_request) - def send_scp_request(self, scp_request: AbstractSCPRequest): - self.send(self.get_scp_data(scp_request)) - def __repr__(self): return ( f"BMPConnection(" diff --git a/spinnman/connections/udp_packet_connections/scamp_connection.py b/spinnman/connections/udp_packet_connections/scamp_connection.py index 9ae9f70bf..738317d4d 100644 --- a/spinnman/connections/udp_packet_connections/scamp_connection.py +++ b/spinnman/connections/udp_packet_connections/scamp_connection.py @@ -114,24 +114,6 @@ def receive_scp_response_with_address( result, sequence = _TWO_SHORTS.unpack_from(data, 10) return SCPResult(result), sequence, data, 2, addr, port - @overrides(AbstractSCPConnection.send_scp_request) - def send_scp_request(self, scp_request: AbstractSCPRequest): - self.send(self.get_scp_data(scp_request)) - - def send_scp_request_to( - self, scp_request: AbstractSCPRequest, - x: int, y: int, ip_address: str): - """ - - :param AbstractSCPRequest scp_request: - :param int x: - :param int y: - :param str ip_address: - """ - self.send_to( - self.get_scp_data(scp_request, x, y), - (str(ip_address), SCP_SCAMP_PORT)) - def __repr__(self) -> str: return ( f"SCAMPConnection(chip_x={self._chip_x}, chip_y={self._chip_y}, " diff --git a/spinnman/extended/extended_transceiver.py b/spinnman/extended/extended_transceiver.py index ba02a965d..3d5fb272f 100644 --- a/spinnman/extended/extended_transceiver.py +++ b/spinnman/extended/extended_transceiver.py @@ -17,7 +17,6 @@ import io import os import logging -import random import struct import time from typing import Optional @@ -89,34 +88,6 @@ def scamp_connection_selector(self) -> ConnectionSelector: """ raise NotImplementedError - def send_scp_message(self, message, connection=None): - """ - Sends an SCP message, without expecting a response. - - :param message: The message to send - :type message: - spinnman.messages.scp.abstract_messages.AbstractSCPRequest - :param SCAMPConnection connection: - The connection to use (omit to pick a random one) - :raise SpinnmanTimeoutException: - If there is a timeout before a message is received - :raise SpinnmanInvalidParameterException: - If one of the fields of the received message is invalid - :raise SpinnmanInvalidPacketException: - * If the message is not a recognised packet type - * If a packet is received that is not a valid response - :raise SpinnmanUnsupportedOperationException: - If no connection can send the type of message given - :raise SpinnmanIOException: - If there is an error sending the message or receiving the response - :raise SpinnmanUnexpectedResponseCodeException: - If the response is not one of the expected codes - """ - if connection is None: - connection = self.scamp_connections[random.randint( - 0, len(self.scamp_connections) - 1)] - connection.send_scp_request(message) - def is_connected(self, connection=None): """ Determines if the board can be contacted via SCAMP diff --git a/spinnman/spalloc/spalloc_scp_connection.py b/spinnman/spalloc/spalloc_scp_connection.py index bfd42d377..6b2bff7a0 100644 --- a/spinnman/spalloc/spalloc_scp_connection.py +++ b/spinnman/spalloc/spalloc_scp_connection.py @@ -61,10 +61,6 @@ def receive_scp_response(self, timeout: Optional[float] = 1.0) -> Tuple[ result, sequence = _TWO_SHORTS.unpack_from(data, 10) return SCPResult(result), sequence, data, 2 - @overrides(SCAMPConnection.send_scp_request) - def send_scp_request(self, scp_request: AbstractSCPRequest): - self.send(self.get_scp_data(scp_request)) - @overrides(SCAMPConnection.get_scp_data) def get_scp_data( self, scp_request: AbstractSCPRequest, diff --git a/unittests/connection_tests/test_udp_connection.py b/unittests/connection_tests/test_udp_connection.py deleted file mode 100644 index a417d5330..000000000 --- a/unittests/connection_tests/test_udp_connection.py +++ /dev/null @@ -1,84 +0,0 @@ -# Copyright (c) 2014 The University of Manchester -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import unittest -from spinnman.connections.udp_packet_connections import SCAMPConnection -from spinnman.config_setup import unittest_setup -from spinnman.constants import LOCAL_HOST -from spinnman.exceptions import SpinnmanTimeoutException -from spinnman.messages.scp.impl import GetVersion, ReadLink, ReadMemory -from spinnman.messages.scp.enums import SCPResult -from spinnman.messages.scp.impl.get_version_response import GetVersionResponse -from spinnman.board_test_configuration import BoardTestConfiguration - - -class TestUDPConnection(unittest.TestCase): - - def setUp(self): - unittest_setup() - self.board_config = BoardTestConfiguration() - - def test_scp_version_request_and_response_board(self): - self.board_config.set_up_remote_board(version=5) - connection = SCAMPConnection( - remote_host=self.board_config.remotehost) - scp_req = GetVersion(0, 0, 0) - scp_response = GetVersionResponse() - connection.send_scp_request(scp_req) - if self.board_config.remotehost == LOCAL_HOST: - raise unittest.SkipTest( - "Can not test the rest without a ral board") - _, _, data, offset = connection.receive_scp_response() - scp_response.read_bytestring(data, offset) - print(scp_response.version_info) - self.assertEqual( - scp_response._scp_response_header._result, SCPResult.RC_OK) - - def test_scp_read_link_request_and_response_board(self): - self.board_config.set_up_remote_board(version=5) - connection = SCAMPConnection( - remote_host=self.board_config.remotehost) - scp_link = ReadLink((0, 0, 0), 0, 0x70000000, 250) - connection.send_scp_request(scp_link) - if self.board_config.remotehost == LOCAL_HOST: - raise unittest.SkipTest( - "Can not test the rest without a ral board") - result, _, _, _ = connection.receive_scp_response() - self.assertEqual(result, SCPResult.RC_OK) - - def test_scp_read_memory_request_and_response_board(self): - self.board_config.set_up_remote_board(version=5) - connection = SCAMPConnection( - remote_host=self.board_config.remotehost) - scp_link = ReadMemory((0, 0, 0), 0x70000000, 256) - connection.send_scp_request(scp_link) - if self.board_config.remotehost == LOCAL_HOST: - raise unittest.SkipTest( - "Can not test the rest without a ral board") - result, _, _, _ = connection.receive_scp_response() - self.assertEqual(result, SCPResult.RC_OK) - - def test_send_scp_request_to_nonexistent_host(self): - # Microsoft invalid IP address. For more details see: - # https://answers.microsoft.com/en-us/windows/forum/windows_vista-networking/invalid-ip-address-169254xx/ce096728-e2b7-4d54-80cc-52a4ed342870 - _NOHOST = "169.254.254.254" - with self.assertRaises(SpinnmanTimeoutException): - connection = SCAMPConnection(remote_host=_NOHOST) - scp = ReadMemory((0, 0, 0), 0, 256) - connection.send_scp_request(scp) - _, _, _, _ = connection.receive_scp_response(2) - - -if __name__ == '__main__': - unittest.main()