From 7d2df29b344c600540e2e6c31f6972f416b6ef61 Mon Sep 17 00:00:00 2001 From: christian-B Date: Thu, 2 Jul 2026 15:03:38 +0100 Subject: [PATCH 1/2] split _get_sv_data --- spinnman/transceiver/base_transceiver.py | 26 ++++++++++++++---------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/spinnman/transceiver/base_transceiver.py b/spinnman/transceiver/base_transceiver.py index 5d527b58..9c199eac 100644 --- a/spinnman/transceiver/base_transceiver.py +++ b/spinnman/transceiver/base_transceiver.py @@ -710,22 +710,26 @@ def get_cpu_infos( def get_clock_drift(self, x: int, y: int) -> float: drift_fp = 1 << 17 - drift_b = self._get_sv_data(x, y, SystemVariableDefinition.clock_drift) + drift_b = self._get_int_sv_data(x, y, SystemVariableDefinition.clock_drift) drift = struct.unpack(" Union[int, bytearray]: + data_item: SystemVariableDefinition) -> int: addr = SYSTEM_VARIABLE_BASE_ADDRESS + data_item.offset - if data_item.data_type.is_byte_array: - size = cast(int, data_item.array_size) - # Do not need to decode the bytes of a byte array - return self.read_memory(x, y, addr, size) return struct.unpack_from( data_item.data_type.struct_code, self.read_memory(x, y, addr, data_item.data_type.value))[0] + def _get_array_sv_data( + self, x: int, y: int, + data_item: SystemVariableDefinition) -> bytearray: + addr = SYSTEM_VARIABLE_BASE_ADDRESS + data_item.offset + size = cast(int, data_item.array_size) + # Do not need to decode the bytes of a byte array + return self.read_memory(x, y, addr, size) + @staticmethod def __get_user_register_address_from_core( p: int, user: UserRegister) -> int: @@ -769,10 +773,10 @@ def get_iobuf(self, core_subsets: Optional[CoreSubsets] = None ) -> Iterable[IOBuffer]: # making the assumption that all chips have the same iobuf size. if self._iobuf_size is None: - self._iobuf_size = cast(int, self._get_sv_data( + self._iobuf_size = self._get_int_sv_data( AbstractSCPRequest.DEFAULT_DEST_X_COORD, AbstractSCPRequest.DEFAULT_DEST_Y_COORD, - SystemVariableDefinition.iobuf_size)) + SystemVariableDefinition.iobuf_size) # Get all the cores if the subsets are not given # TODO is core_subsets ever None if core_subsets is None: @@ -1280,8 +1284,8 @@ def get_multicast_routes( self, x: int, y: int, app_id: Optional[int] = None) -> List[MulticastRoutingEntry]: try: - base_address = cast(int, self._get_sv_data( - x, y, SystemVariableDefinition.router_table_copy_address)) + base_address = self._get_int_sv_data( + x, y, SystemVariableDefinition.router_table_copy_address) process = GetMultiCastRoutesProcess( self._scamp_connection_selector, app_id) return process.get_routes(x, y, base_address) From 1e4fc4dafcebf46e57f66af6f72974b82e1cd9a7 Mon Sep 17 00:00:00 2001 From: christian-B Date: Thu, 2 Jul 2026 15:06:36 +0100 Subject: [PATCH 2/2] flake8 --- spinnman/transceiver/base_transceiver.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spinnman/transceiver/base_transceiver.py b/spinnman/transceiver/base_transceiver.py index 9c199eac..0e94e31c 100644 --- a/spinnman/transceiver/base_transceiver.py +++ b/spinnman/transceiver/base_transceiver.py @@ -710,7 +710,8 @@ def get_cpu_infos( def get_clock_drift(self, x: int, y: int) -> float: drift_fp = 1 << 17 - drift_b = self._get_int_sv_data(x, y, SystemVariableDefinition.clock_drift) + drift_b = self._get_int_sv_data( + x, y, SystemVariableDefinition.clock_drift) drift = struct.unpack("