• 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

46.67
/spinnman/processes/read_router_diagnostics_process.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 spinnman.messages.scp.impl.read_memory import ReadMemory, Response
1✔
17
from spinnman.model import RouterDiagnostics
1✔
18
from .abstract_multi_connection_process import AbstractMultiConnectionProcess
1✔
19
from .abstract_multi_connection_process_connection_selector import (
1✔
20
    ConnectionSelector)
21

22
_N_REGISTERS = 16
1✔
23
_ONE_WORD = struct.Struct("<I")
1✔
24

25

26
class ReadRouterDiagnosticsProcess(
1✔
27
        AbstractMultiConnectionProcess[Response]):
28
    """
29
    A process for reading the diagnostic data block from a SpiNNaker router.
30
    """
31
    __slots__ = (
1✔
32
        "_control_register",
33
        "_error_status",
34
        "_register_values")
35

36
    def __init__(self, connection_selector: ConnectionSelector):
1✔
37
        """
38
        :param ConnectionSelector connection_selector:
39
        """
40
        super().__init__(connection_selector)
×
41
        self._control_register = 0
×
42
        self._error_status = 0
×
43
        self._register_values = [0] * _N_REGISTERS
×
44

45
    def __handle_control_register_response(self, response: Response):
1✔
46
        self._control_register = _ONE_WORD.unpack_from(
×
47
            response.data, response.offset)[0]
48

49
    def __handle_error_status_response(self, response: Response):
1✔
50
        self._error_status = _ONE_WORD.unpack_from(
×
51
            response.data, response.offset)[0]
52

53
    def __handle_register_response(self, response: Response):
1✔
54
        for register in range(_N_REGISTERS):
×
55
            self._register_values[register] = _ONE_WORD.unpack_from(
×
56
                response.data, response.offset + (register * 4))[0]
57

58
    def get_router_diagnostics(self, x: int, y: int) -> RouterDiagnostics:
1✔
59
        """
60
        :param int x:
61
        :param int y:
62
        :rtype: RouterDiagnostics
63
        """
64
        with self._collect_responses():
×
65
            coords = x, y, 0
×
66
            self._send_request(ReadMemory(coords, 0xe1000000, 4),
×
67
                               self.__handle_control_register_response)
68
            self._send_request(ReadMemory(coords, 0xe1000014, 4),
×
69
                               self.__handle_error_status_response)
70
            self._send_request(ReadMemory(coords, 0xe1000300, 16 * 4),
×
71
                               self.__handle_register_response)
72

73
        return RouterDiagnostics(self._control_register, self._error_status,
×
74
                                 self._register_values)
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