• 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

71.43
/spinnman/messages/scp/impl/write_memory.py
1
# Copyright (c) 2014 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
from spinn_utilities.overrides import overrides
1✔
16
from spinn_utilities.typing.coords import XYP
1✔
17
from spinnman.constants import address_length_dtype
1✔
18
from spinnman.messages.scp import SCPRequestHeader
1✔
19
from spinnman.messages.scp.abstract_messages import AbstractSCPRequest
1✔
20
from spinnman.messages.scp.enums import SCPCommand
1✔
21
from spinnman.messages.sdp import SDPFlag, SDPHeader
1✔
22
from .check_ok_response import CheckOKResponse
1✔
23

24

25
class WriteMemory(AbstractSCPRequest[CheckOKResponse]):
1✔
26
    """
27
    A request to write memory on a chip.
28
    """
29
    __slots__ = "_data_to_write",
1✔
30

31
    def __init__(self, coordinates: XYP, base_address: int, data: bytes):
1✔
32
        """
33
        :param tuple(int,int,int) coordinates:
34
            The coordinates of the chip, X and Y between 0 and 255, and P
35
            between 0 and 17 (normally 0 when writing to SDRAM; may be other
36
            values when writing to ITCM or DTCM);
37
            these are not checked due to speed restrictions
38
        :param int base_address: The base_address to start writing to
39
            the base address is not checked to see if its not valid
40
        :param data: between 1 and 256 bytes of data to write;
41
            this is not checked due to speed restrictions
42
        :type data: bytearray or bytes
43
        """
44
        size = len(data)
×
45
        x, y, cpu = coordinates
×
46
        super().__init__(
×
47
            SDPHeader(
48
                flags=SDPFlag.REPLY_EXPECTED, destination_port=0,
49
                destination_cpu=cpu, destination_chip_x=x,
50
                destination_chip_y=y),
51
            SCPRequestHeader(command=SCPCommand.CMD_WRITE),
52
            argument_1=base_address, argument_2=size,
53
            argument_3=address_length_dtype[
54
                (base_address % 4), (size % 4)].value,
55
            data=None)
56
        self._data_to_write = data
×
57

58
    @property
1✔
59
    def bytestring(self) -> bytes:
1✔
60
        return super().bytestring + bytes(self._data_to_write)
×
61

62
    @overrides(AbstractSCPRequest.get_scp_response)
1✔
63
    def get_scp_response(self) -> CheckOKResponse:
1✔
64
        return CheckOKResponse("write to memory", "CMD_WRITE")
×
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