From 561ee3ad8651d5f7527d65089aa04708e91635ff Mon Sep 17 00:00:00 2001 From: Henrik Wahlqvist Date: Wed, 21 May 2025 09:18:07 +0200 Subject: [PATCH] Continuation of new RTE checkpoint interface * Make it possible to set the number of IDs * Don't use old IDs, use digits Change-Id: I3c43406d56eab19ee3bf762b23a90f9e7307b704 --- NOTICE | 91 ++++++++------------------- docs/project_config.md | 6 ++ powertrain_build/build_proj_config.py | 1 + powertrain_build/sched_funcs.py | 34 +++++++--- 4 files changed, 58 insertions(+), 74 deletions(-) diff --git a/NOTICE b/NOTICE index bb17ecf..d64bf8a 100644 --- a/NOTICE +++ b/NOTICE @@ -12,7 +12,7 @@ Notices Report Content Components: -Coverage 7.8.0: http://nedbatchelder.com/code/modules/coverage.html : Apache License 2.0 +Coverage 7.8.2: http://nedbatchelder.com/code/modules/coverage.html : Apache License 2.0 exceptiongroup 1.3.0: https://github.com/python-trio/exceptiongroup : MIT License flake8 7.2.0: https://gitlab.com/pycqa/flake8 : MIT License gitdb 4.0.12: http://github.com/gitpython-developers/gitdb : BSD 3-clause "New" or "Revised" License @@ -43,69 +43,8 @@ voluptuous 0.15.2: http://pypi.python.org/pypi/voluptuous : BSD 3-clause "New" o Copyright Text: -Coverage 7.8.0 pypi:coverage/7.8.0: http://nedbatchelder.com/code/modules/coverage.html - (c) - else: - c.post_fork() - self._collectors[:] = keep_collectors - - if self._collectors: - - (c) - yield code - - - (c) - else: - c.post_fork() - self._collectors[:] = keep_collectors - - if self._collectors: - - (c) - yield code - - - (c) for c in re.split(r"(\d - -def human_sorted(strings: Iterable[str]) -> list[str]: - - (c) for c in re.split(r"(\d - -def human_sorted(strings: Iterable[str]) -> list[str]: - - (c) for c in self.code) - - def add_line(self, line: str) -> None: - - (c) for c in self.code) - - def add_line(self, line: str) -> None: - - (c) for c in text - print(u"All OK with {encoding}") - encoding = "{encoding}" - """, - - (c) for c in text - source_text = source.format(encoding=encoding, text=text, ords=ords) - zf.writestr(filename, source_text.encode(encoding)) - - with zipfile.ZipFile("tests/zip1.zip", "w") as zf: - - (c)?c:a(c)):null - Copyright 2001 Gareth Rees. All rights reserved. - - Copyright 2004- - ) - - Copyright 2004-2025 Ned Batchelder. All rights reserved. - - Copyright 2004. - Copyright Software Freedom Conservancy, Inc. - - ©�*��{ǰ(���2 - +Coverage 7.8.2 pypi:coverage/7.8.2: http://nedbatchelder.com/code/modules/coverage.html + No Copyrights found exceptiongroup 1.3.0 pypi:exceptiongroup/1.3.0: https://github.com/python-trio/exceptiongroup No Copyrights found flake8 7.2.0 pypi:flake8/7.2.0: https://gitlab.com/pycqa/flake8 @@ -2639,7 +2578,27 @@ modification, are permitted provided that the following conditions are met: $HEADER$ Packaging 25.0 pypi:packaging/25.0: https://github.com/pypa/packaging - No Copyrights found + Copyright (c) 2017-present Ofek Lev + + Copyright (c) Donald Stufft and individual contributors. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + + copyright = ABOUT + +# -- Options for HTML output -------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + pbr 6.1.1 pypi:pbr/6.1.1: http://openstack.org Copyright (C) 2005 Association of Universities for Research in Astronomy (AURA) @@ -13757,7 +13716,7 @@ modification, are permitted provided that the following conditions are met: Licenses: Apache License 2.0 -(Coverage 7.8.0, Packaging 25.0, pbr 6.1.1, powertrain-build 1.5.0, psf-requests 2.32.3) +(Coverage 7.8.2, Packaging 25.0, pbr 6.1.1, powertrain-build 1.5.0, psf-requests 2.32.3) Apache License Version 2.0, January 2004 diff --git a/docs/project_config.md b/docs/project_config.md index 198035a..2730926 100644 --- a/docs/project_config.md +++ b/docs/project_config.md @@ -123,6 +123,7 @@ This key is used to set individual options to match the old ECU types, see examp "generateDummyVar": true, "generateInterfaceHeaders": false, "generateRteCheckpointIds": false, + "rteCheckpointIdSize": null, "generateYamlInterfaceFile": false, "includeAllEnums": false, "mapToRteEnums": false, @@ -187,6 +188,11 @@ Paths should be relative to the location of *ProjectCfg.json* file. Add RTE checkpoint ID definitions to the generated scheduling functions. +#### rteCheckpointIdSize + +The number of RTE checkpoint call IDs that are available. +Default is None/null. + #### generateYamlInterfaceFile Generate a yaml file containing all metadata for the project. diff --git a/powertrain_build/build_proj_config.py b/powertrain_build/build_proj_config.py index 1015f68..813f059 100644 --- a/powertrain_build/build_proj_config.py +++ b/powertrain_build/build_proj_config.py @@ -72,6 +72,7 @@ class BuildProjConfig: 'generateDummyVar': False, 'generateInterfaceHeaders': False, 'generateRteCheckpointIds': False, + 'rteCheckpointIdSize': None, 'generateYamlInterfaceFile': False, 'includeAllEnums': False, 'mapToRteEnums': False, diff --git a/powertrain_build/sched_funcs.py b/powertrain_build/sched_funcs.py index a2cb85b..00a59e2 100644 --- a/powertrain_build/sched_funcs.py +++ b/powertrain_build/sched_funcs.py @@ -57,19 +57,25 @@ class SchedFuncs(ProblemLogger): Args: generate_rte_checkpoint_calls (bool): Generate RTE function checkpoint calls. """ - generate_rte_checkpoint_ids = self._prj_cfg.get_code_generation_config("generateRteCheckpointIds") - include_name = self._prj_cfg.get_composition_config("softwareComponentName") - function_name = self._prj_cfg.get_composition_config("compositionName") - if function_name is None: - function_name = include_name dst_dir = self._prj_cfg.get_src_code_dst_dir() unit_raster_cfg = self._prj_cfg.get_units_raster_cfg() per_unit_cfg = self._unit_cfg.get_per_unit_cfg() prefix = self._prj_cfg.get_scheduler_prefix() + unit_counter = 1 + generate_rte_checkpoint_ids = self._prj_cfg.get_code_generation_config("generateRteCheckpointIds") + rte_checkpoint_id_size = self._prj_cfg.get_code_generation_config("rteCheckpointIdSize") + if rte_checkpoint_id_size is None: + if generate_rte_checkpoint_calls: + self.warning("RTE checkpoint ID size not set, assuming size is the same as the number of units.") + rte_checkpoint_id_size = len(self._prj_cfg.get_all_units()) + include_name = self._prj_cfg.get_composition_config("softwareComponentName") + function_name = self._prj_cfg.get_composition_config("compositionName") + if function_name is None: + function_name = include_name + init_ext_def_s = "" init_call_s = f'#include "{build_defs.CVC_CODE_START}"\n\n' init_call_s += f'void {prefix}VcExtINI(void)\n{{\n' - for raster in unit_raster_cfg['SampleTimes']: if raster == "init": for unit in unit_raster_cfg['Rasters'][raster]: @@ -101,6 +107,10 @@ class SchedFuncs(ProblemLogger): call_str = f'#include "{build_defs.CVC_CODE_START}"\n' call_str += f'void {prefix}{raster}(void)\n{{\n' for unit in unit_raster_cfg['Rasters'][raster]: + if unit_counter > rte_checkpoint_id_size: + self.critical( + 'RTE checkpoint ID size %d is smaller than the number of units.', rte_checkpoint_id_size + ) if unit not in SchedFuncs.RESTART_FNC_EXCLUDE and 'code_generator' in per_unit_cfg[unit]: code_generator = per_unit_cfg[unit]['code_generator'] else: @@ -125,13 +135,21 @@ class SchedFuncs(ProblemLogger): ) # new call_str += ( - 'Rte_Call_alive_WdgMSupervisedEntity_' - f'AR_{raster}_CheckpointReached(ID_{unit_name});\n' + ' Rte_Call_alive_WdgMSupervisedEntity_' + f'AR_{raster}_CheckpointReached({unit_counter});\n' ) call_str += f' {unit_name}();\n' if unit_name not in SchedFuncs.RESTART_FNC_EXCLUDE: init_ext_def_s += f'extern void RESTART_{unit_name}(void);\n' init_call_s += f' RESTART_{unit_name}();\n' + unit_counter += 1 + if generate_rte_checkpoint_calls: + # Also call remaining dummy IDs, "new way" only + for i in range(unit_counter, rte_checkpoint_id_size + 1): + call_str += ( + ' Rte_Call_alive_WdgMSupervisedEntity_' + f'AR_{raster}_CheckpointReached({i});\n' + ) ext_def_str += '\n' call_str += '}\n' call_str += f'#include "{build_defs.CVC_CODE_END}"\n\n'