• 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

51.06
/spinnman/spalloc/spalloc_scp_connection.py
1
# Copyright (c) 2022 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 Optional, Tuple
1✔
17
from spinn_utilities.abstract_base import AbstractBase
1✔
18
from spinn_utilities.overrides import overrides
1✔
19
from spinnman.connections.udp_packet_connections import SCAMPConnection
1✔
20
from spinnman.messages.sdp import SDPMessage, SDPFlag
1✔
21
from spinnman.messages.scp.abstract_messages import AbstractSCPRequest
1✔
22
from spinnman.messages.scp.enums import SCPResult
1✔
23
from .spalloc_proxied_connection import SpallocProxiedConnection
1✔
24

25
_TWO_SHORTS = struct.Struct("<2H")
1✔
26
_TWO_SKIP: bytes = b'\0\0'
1✔
27

28

29
class SpallocSCPConnection(
1✔
30
        SCAMPConnection, SpallocProxiedConnection,
31
        metaclass=AbstractBase):
32
    """
33
    The socket interface supported by proxied sockets. The socket will always
34
    be talking to a specific board. This emulates a
35
    :py:class:`SCAMPConnection`.
36
    """
37
    __slots__ = ()
1✔
38

39
    def __init__(self, x, y):
1✔
40
        super(SpallocSCPConnection, self).__init__(x, y)
×
41

42
    @overrides(SCAMPConnection.receive_sdp_message)
1✔
43
    def receive_sdp_message(
1✔
44
            self, timeout: Optional[float] = None) -> SDPMessage:
45
        data = self.receive(timeout)
×
46
        return SDPMessage.from_bytestring(data, 2)
×
47

48
    @overrides(SCAMPConnection.send_sdp_message)
1✔
49
    def send_sdp_message(self, sdp_message: SDPMessage):
1✔
50
        # If a reply is expected, the connection should
51
        if sdp_message.sdp_header.flags == SDPFlag.REPLY_EXPECTED:
×
52
            sdp_message.sdp_header.update_for_send(self.chip_x, self.chip_y)
×
53
        else:
54
            sdp_message.sdp_header.update_for_send(0, 0)
×
55
        self.send(_TWO_SKIP + sdp_message.bytestring)
×
56

57
    @overrides(SCAMPConnection.receive_scp_response)
1✔
58
    def receive_scp_response(
1✔
59
            self, timeout=1.0) -> Tuple[SCPResult, int, bytes, int]:
60
        data = self.receive(timeout)
×
61
        result, sequence = _TWO_SHORTS.unpack_from(data, 10)
×
62
        return SCPResult(result), sequence, data, 2
×
63

64
    @overrides(SCAMPConnection.send_scp_request)
1✔
65
    def send_scp_request(self, scp_request: AbstractSCPRequest):
1✔
66
        self.send(self.get_scp_data(scp_request))
×
67

68
    @overrides(SCAMPConnection.get_scp_data)
1✔
69
    def get_scp_data(
1✔
70
            self, scp_request: AbstractSCPRequest, x=None, y=None) -> bytes:
71
        if x is None:
×
72
            x = self.chip_x
×
73
        if y is None:
×
74
            y = self.chip_y
×
75
        scp_request.sdp_header.update_for_send(x, y)
×
76
        return _TWO_SKIP + scp_request.bytestring
×
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