|
19 | 19 | import struct |
20 | 20 | from enum import Enum, IntEnum |
21 | 21 | from typing import ( |
22 | | - Any, BinaryIO, Iterable, List, Optional, Set, Tuple, Union, |
23 | | - TYPE_CHECKING) |
| 22 | + Any, BinaryIO, Iterable, List, Optional, Set, Tuple, TYPE_CHECKING) |
24 | 23 |
|
25 | 24 | from spinn_utilities.config_holder import get_config_bool, get_report_path |
26 | 25 | from spinn_utilities.overrides import overrides |
@@ -489,7 +488,7 @@ def _generate_data_in_report( |
489 | 488 |
|
490 | 489 | def send_data_into_spinnaker( |
491 | 490 | self, x: int, y: int, base_address: int, |
492 | | - data: Union[BinaryIO, bytes, str, int], *, |
| 491 | + data: BinaryIO | bytearray | bytes | str | int, *, |
493 | 492 | n_bytes: Optional[int] = None, offset: int = 0) -> None: |
494 | 493 | """ |
495 | 494 | Sends a block of data into SpiNNaker to a given chip. |
@@ -606,7 +605,7 @@ def __open_connection(self) -> SCAMPConnection: |
606 | 605 |
|
607 | 606 | def _send_data_via_extra_monitors( |
608 | 607 | self, destination_chip: Chip, start_address: int, |
609 | | - data_to_write: bytes) -> None: |
| 608 | + data_to_write: bytearray | bytes) -> None: |
610 | 609 | """ |
611 | 610 | Sends data using the extra monitor cores. |
612 | 611 |
|
@@ -739,7 +738,7 @@ def _read_in_missing_seq_nums( |
739 | 738 | return seen_last, seen_all |
740 | 739 |
|
741 | 740 | def _outgoing_retransmit_missing_seq_nums( |
742 | | - self, data_to_write: bytes, missing: Set[int], |
| 741 | + self, data_to_write: bytearray | bytes, missing: Set[int], |
743 | 742 | connection: SCAMPConnection) -> None: |
744 | 743 | """ |
745 | 744 | Transmits back into SpiNNaker the missing data based off missing |
@@ -772,7 +771,7 @@ def __position_from_seq_number(seq_num: int) -> int: |
772 | 771 | return BYTES_IN_FULL_PACKET_WITH_KEY * seq_num |
773 | 772 |
|
774 | 773 | def __make_data_in_stream_message( |
775 | | - self, data_to_write: bytes, seq_num: int, |
| 774 | + self, data_to_write: bytearray | bytes, seq_num: int, |
776 | 775 | position: Optional[int]) -> Tuple[SDPMessage, int]: |
777 | 776 | """ |
778 | 777 | Determine the data needed to be sent to the SpiNNaker machine |
@@ -833,7 +832,7 @@ def __send_tell_flag(self, connection: SCAMPConnection) -> None: |
833 | 832 | _DataInCommands.SEND_TELL, self._transaction_id))) |
834 | 833 |
|
835 | 834 | def _send_all_data_based_packets( |
836 | | - self, data_to_write: bytes, start_address: int, |
| 835 | + self, data_to_write: bytearray | bytes, start_address: int, |
837 | 836 | connection: SCAMPConnection) -> None: |
838 | 837 | """ |
839 | 838 | Send all the data as one block. |
@@ -994,7 +993,7 @@ def unset_cores_for_data_streaming(self) -> None: |
994 | 993 | def get_data( |
995 | 994 | self, extra_monitor: ExtraMonitorSupportMachineVertex, |
996 | 995 | placement: Placement, memory_address: int, |
997 | | - length_in_bytes: int) -> bytes: |
| 996 | + length_in_bytes: int) -> bytearray: |
998 | 997 | """ |
999 | 998 | Gets data from a given core and memory address. |
1000 | 999 |
|
@@ -1243,7 +1242,7 @@ def _determine_and_retransmit_missing_seq_nums( |
1243 | 1242 |
|
1244 | 1243 | # build SDP message and send it to the core |
1245 | 1244 | connection.send_sdp_message(self.__make_data_out_message( |
1246 | | - placement, data)) |
| 1245 | + placement, bytes(data))) |
1247 | 1246 |
|
1248 | 1247 | # sleep for ensuring core doesn't lose packets |
1249 | 1248 | time.sleep(self._TIMEOUT_FOR_SENDING_IN_SECONDS) |
|
0 commit comments