• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SpiNNakerManchester / SpiNNMan / 6574804013

19 Oct 2023 12:47PM UTC coverage: 51.937% (+1.2%) from 50.777%
6574804013

Pull #327

github

Christian-B
typing changes
Pull Request #327: Type Annotations and Checking

105 of 1288 branches covered (0.0%)

Branch coverage included in aggregate %.

2375 of 2375 new or added lines in 180 files covered. (100.0%)

4775 of 8108 relevant lines covered (58.89%)

0.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

69.05
/spinnman/connections/udp_packet_connections/bmp_connection.py
1
# Copyright (c) 2015 The University of Manchester
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
6
#
7
#     https://www.apache.org/licenses/LICENSE-2.0
8
#
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14

15
import struct
1✔
16
from typing import Sequence, Tuple
1✔
17
from spinn_utilities.overrides import overrides
1✔
18
from .udp_connection import UDPConnection
1✔
19
from spinnman.constants import SCP_SCAMP_PORT
1✔
20
from spinnman.messages.scp.enums import SCPResult
1✔
21
from spinnman.messages.scp.abstract_messages import AbstractSCPRequest
1✔
22
from spinnman.connections.abstract_classes import AbstractSCPConnection
1✔
23
from spinnman.model import BMPConnectionData
1✔
24

25
_TWO_SHORTS = struct.Struct("<2H")
1✔
26
_TWO_SKIP = struct.Struct("<2x")
1✔
27

28

29
class BMPConnection(UDPConnection, AbstractSCPConnection):
1✔
30
    """
31
    A BMP connection which supports queries to the BMP of a SpiNNaker machine.
32
    """
33
    __slots__ = ("_boards", )
1✔
34

35
    def __init__(self, connection_data: BMPConnectionData):
1✔
36
        """
37
        :param BMPConnectionData connection_data:
38
            The description of what to connect to.
39
        """
40
        port = SCP_SCAMP_PORT if connection_data.port_num is None\
×
41
            else connection_data.port_num
42
        super().__init__(
×
43
            remote_host=connection_data.ip_address, remote_port=port)
44
        self._boards = connection_data.boards
×
45

46
    @property
1✔
47
    def boards(self) -> Sequence[int]:
1✔
48
        """
49
        The set of boards supported by the BMP.
50

51
        :rtype: iterable(int)
52
        """
53
        return self._boards
×
54

55
    @property
1✔
56
    @overrides(AbstractSCPConnection.chip_x, extend_doc=False)
1✔
57
    def chip_x(self) -> int:
1✔
58
        """
59
        Defined to satisfy the AbstractSCPConnection - always 0 for a BMP.
60
        """
61
        return 0
×
62

63
    @property
1✔
64
    @overrides(AbstractSCPConnection.chip_y, extend_doc=False)
1✔
65
    def chip_y(self) -> int:
1✔
66
        """
67
        Defined to satisfy the AbstractSCPConnection - always 0 for a BMP.
68
        """
69
        return 0
×
70

71
    @overrides(AbstractSCPConnection.get_scp_data)
1✔
72
    def get_scp_data(self, scp_request: AbstractSCPRequest) -> bytes:
1✔
73
        scp_request.sdp_header.update_for_send(0, 0)
×
74
        return _TWO_SKIP.pack() + scp_request.bytestring
×
75

76
    @overrides(AbstractSCPConnection.receive_scp_response)
1✔
77
    def receive_scp_response(self, timeout=1.0) -> Tuple[
1✔
78
            SCPResult, int, bytes, int]:
79
        data = self.receive(timeout)
×
80
        result, sequence = _TWO_SHORTS.unpack_from(data, 10)
×
81
        return SCPResult(result), sequence, data, 2
×
82

83
    @overrides(AbstractSCPConnection.send_scp_request)
1✔
84
    def send_scp_request(self, scp_request: AbstractSCPRequest):
1✔
85
        self.send(self.get_scp_data(scp_request))
×
86

87
    def __repr__(self):
1✔
88
        return (
×
89
            f"BMPConnection("
90
            f"boards={self._boards}, local_host={self.local_ip_address}, "
91
            f"local_port={self.local_port}, "
92
            f"remote_host={self.remote_ip_address}, "
93
            f"remote_port={self.remote_port})")
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc