Bug fixes to rte_dummy.py
Introduced in: 75b3991f5720dcbe78f06def9a85fa55169cab65 * Rte_CData_* functions were never declared. * Type definitions of Maps should be structs. Change-Id: Id8d371e6fd0dee7e7accf480a5a09e568db80af4
This commit is contained in:
parent
ed73202f9d
commit
b42d107422
@ -95,8 +95,15 @@ class RteDummy(ProblemLogger):
|
|||||||
for signal_name, signal_data in self.calibration_variables.items():
|
for signal_name, signal_data in self.calibration_variables.items():
|
||||||
if isinstance(signal_data["width"], list):
|
if isinstance(signal_data["width"], list):
|
||||||
if signal_name.startswith("m") and signal_name[-2:] not in ["_r", "_c"]:
|
if signal_name.startswith("m") and signal_name[-2:] not in ["_r", "_c"]:
|
||||||
typedefs.append(f"typedef {signal_data['type']} {signal_data['autosar_type']};\n")
|
typedefs.append(
|
||||||
typedefs.append("\n")
|
f"typedef {signal_data['type']} {signal_data['autosar_type']}_e[{signal_data['width'][0]}];\n"
|
||||||
|
)
|
||||||
|
typedefs.append(
|
||||||
|
"typedef struct \n"
|
||||||
|
"{\n"
|
||||||
|
f" {signal_data['autosar_type']}_e {signal_data['autosar_type']}[{signal_data['width'][1]}];\n"
|
||||||
|
f"}} {signal_data['autosar_type']};\n\n"
|
||||||
|
)
|
||||||
|
|
||||||
return "".join(typedefs)
|
return "".join(typedefs)
|
||||||
|
|
||||||
@ -140,37 +147,6 @@ class RteDummy(ProblemLogger):
|
|||||||
|
|
||||||
return "\n".join(struct_defines + function_declarations)
|
return "\n".join(struct_defines + function_declarations)
|
||||||
|
|
||||||
def _get_calibration_source_dummy(self):
|
|
||||||
"""Get calibration source dummy code."""
|
|
||||||
if not self.calibration_variables:
|
|
||||||
return ""
|
|
||||||
|
|
||||||
lines_to_write = []
|
|
||||||
swc_name = self.build_cfg.get_composition_config("softwareComponentName")
|
|
||||||
for signal_name, signal_data in self.calibration_variables.items():
|
|
||||||
if isinstance(signal_data["width"], list):
|
|
||||||
# MAPs get typedef:ed to structs and need special data type mapping in calibration.py
|
|
||||||
if signal_name.startswith("m") and signal_name[-2:] not in ["_r", "_c"]:
|
|
||||||
return_type = f'const {signal_data["autosar_type"]}*'
|
|
||||||
return_string = (
|
|
||||||
f"const {signal_data['autosar_type']} dummy; "
|
|
||||||
f"{return_type} dummyPtr = &dummy; "
|
|
||||||
"return dummyPtr;"
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
return_type = f'const {signal_data["type"]}*'
|
|
||||||
return_string = (
|
|
||||||
f"{signal_data['type']} dummy; "
|
|
||||||
f"{return_type} dummyPtr = &dummy; "
|
|
||||||
"return dummyPtr;"
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
return_type = f'{signal_data["type"]}'
|
|
||||||
return_string = f"return ({return_type})0;"
|
|
||||||
lines_to_write.append(f"{return_type} Rte_CData_{swc_name}_{signal_name}(void) {{ {return_string} }}")
|
|
||||||
lines_to_write.append("")
|
|
||||||
return "\n".join(lines_to_write)
|
|
||||||
|
|
||||||
def _get_nvm_source_dummy(self):
|
def _get_nvm_source_dummy(self):
|
||||||
"""Generate NVM source dummy code."""
|
"""Generate NVM source dummy code."""
|
||||||
lines_to_write = []
|
lines_to_write = []
|
||||||
@ -186,6 +162,62 @@ class RteDummy(ProblemLogger):
|
|||||||
lines_to_write.append("")
|
lines_to_write.append("")
|
||||||
return "\n".join(lines_to_write)
|
return "\n".join(lines_to_write)
|
||||||
|
|
||||||
|
def _get_calibration_function_data(self, signal_name, signal_data):
|
||||||
|
""""Get calibration function data.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
signal_name (str): Name of the signal.
|
||||||
|
signal_data (dict): Dictionary containing signal data.
|
||||||
|
Returns:
|
||||||
|
return_type, return_string (tuple): Tuple containing the return type and return string.
|
||||||
|
"""
|
||||||
|
if isinstance(signal_data["width"], list):
|
||||||
|
# MAPs get typedef:ed to structs and need special data type mapping in calibration.py
|
||||||
|
if signal_name.startswith("m") and signal_name[-2:] not in ["_r", "_c"]:
|
||||||
|
return_type = f'const {signal_data["autosar_type"]}*'
|
||||||
|
return_string = (
|
||||||
|
f"const {signal_data['autosar_type']} dummy; "
|
||||||
|
f"{return_type} dummyPtr = &dummy; "
|
||||||
|
"return dummyPtr;"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return_type = f'const {signal_data["type"]}*'
|
||||||
|
return_string = (
|
||||||
|
f"{signal_data['type']} dummy; "
|
||||||
|
f"{return_type} dummyPtr = &dummy; "
|
||||||
|
"return dummyPtr;"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return_type = f'{signal_data["type"]}'
|
||||||
|
return_string = f"return ({return_type})0;"
|
||||||
|
return return_type, return_string
|
||||||
|
|
||||||
|
def _get_calibration_header_dummy(self):
|
||||||
|
"""Get calibration dummy header code."""
|
||||||
|
if not self.calibration_variables:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
lines_to_write = []
|
||||||
|
swc_name = self.build_cfg.get_composition_config("softwareComponentName")
|
||||||
|
for signal_name, signal_data in self.calibration_variables.items():
|
||||||
|
return_type = self._get_calibration_function_data(signal_name, signal_data)[0]
|
||||||
|
lines_to_write.append(f"{return_type} Rte_CData_{swc_name}_{signal_name}(void);")
|
||||||
|
lines_to_write.append("")
|
||||||
|
return "\n".join(lines_to_write)
|
||||||
|
|
||||||
|
def _get_calibration_source_dummy(self):
|
||||||
|
"""Get calibration source dummy code."""
|
||||||
|
if not self.calibration_variables:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
lines_to_write = []
|
||||||
|
swc_name = self.build_cfg.get_composition_config("softwareComponentName")
|
||||||
|
for signal_name, signal_data in self.calibration_variables.items():
|
||||||
|
return_type, return_string = self._get_calibration_function_data(signal_name, signal_data)
|
||||||
|
lines_to_write.append(f"{return_type} Rte_CData_{swc_name}_{signal_name}(void) {{ {return_string} }}")
|
||||||
|
lines_to_write.append("")
|
||||||
|
return "\n".join(lines_to_write)
|
||||||
|
|
||||||
def generate_rte_dummy(self):
|
def generate_rte_dummy(self):
|
||||||
"""Generate RTE dummy files."""
|
"""Generate RTE dummy files."""
|
||||||
src_code_dest_dir = self.build_cfg.get_src_code_dst_dir()
|
src_code_dest_dir = self.build_cfg.get_src_code_dst_dir()
|
||||||
@ -198,6 +230,7 @@ class RteDummy(ProblemLogger):
|
|||||||
type_header_fh.write(self._get_type_header_header())
|
type_header_fh.write(self._get_type_header_header())
|
||||||
type_header_fh.write(self._get_typedef_dummy())
|
type_header_fh.write(self._get_typedef_dummy())
|
||||||
type_header_fh.write(self._get_nvm_header_dummy())
|
type_header_fh.write(self._get_nvm_header_dummy())
|
||||||
|
type_header_fh.write(self._get_calibration_header_dummy())
|
||||||
type_header_fh.write(self._get_type_header_footer())
|
type_header_fh.write(self._get_type_header_footer())
|
||||||
with source_file.open(mode="w", encoding="utf-8") as source_fh:
|
with source_file.open(mode="w", encoding="utf-8") as source_fh:
|
||||||
source_fh.write(self._get_source_header())
|
source_fh.write(self._get_source_header())
|
||||||
|
@ -44,20 +44,21 @@ expected_rte_structs_type_header_header = (
|
|||||||
"#define TRUE 1U\n"
|
"#define TRUE 1U\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
expected_typedefs = "\n"
|
expected_typedefs = ""
|
||||||
|
|
||||||
expected_rte_structs_typedefs = (
|
expected_rte_structs_typedefs = "typedef UInt8 testNameFctList;\n"
|
||||||
"typedef UInt8 testNameFctList;\n"
|
|
||||||
"\n"
|
|
||||||
)
|
|
||||||
|
|
||||||
expected_rte_structs_and_calibration_typedefs = (
|
expected_rte_structs_and_calibration_typedefs = (
|
||||||
"typedef UInt8 testNameFctList;\n"
|
"typedef UInt8 testNameFctList;\n"
|
||||||
"typedef UInt16 dt_mVcSignalOne;\n"
|
"typedef UInt16 dt_mVcSignalOne_e[2];\n"
|
||||||
|
"typedef struct \n"
|
||||||
|
"{\n"
|
||||||
|
" dt_mVcSignalOne_e dt_mVcSignalOne[3];\n"
|
||||||
|
"} dt_mVcSignalOne;\n"
|
||||||
"\n"
|
"\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
expected_type_header_content = (
|
expected_nvm_header_content = (
|
||||||
"struct DUMMY_NVM_LIST_8 *Rte_Pim_DUMMY_NVM_LIST_8(void);\n"
|
"struct DUMMY_NVM_LIST_8 *Rte_Pim_DUMMY_NVM_LIST_8(void);\n"
|
||||||
"void Rte_Read_DUMMY_NVM_LIST_8_DUMMY_NVM_LIST_8(struct DUMMY_NVM_LIST_8 *block);\n"
|
"void Rte_Read_DUMMY_NVM_LIST_8_DUMMY_NVM_LIST_8(struct DUMMY_NVM_LIST_8 *block);\n"
|
||||||
"void Rte_Write_DUMMY_NVM_LIST_8_DUMMY_NVM_LIST_8(struct DUMMY_NVM_LIST_8 *block);\n"
|
"void Rte_Write_DUMMY_NVM_LIST_8_DUMMY_NVM_LIST_8(struct DUMMY_NVM_LIST_8 *block);\n"
|
||||||
@ -66,7 +67,7 @@ expected_type_header_content = (
|
|||||||
"void Rte_Write_DUMMY_NVM_LIST_16_DUMMY_NVM_LIST_16(struct DUMMY_NVM_LIST_16 *block);"
|
"void Rte_Write_DUMMY_NVM_LIST_16_DUMMY_NVM_LIST_16(struct DUMMY_NVM_LIST_16 *block);"
|
||||||
)
|
)
|
||||||
|
|
||||||
expected_rte_structs_type_header_content = (
|
expected_rte_structs_nvm_header_content = (
|
||||||
"typedef struct\n"
|
"typedef struct\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" UInt8 e_dummy;\n"
|
" UInt8 e_dummy;\n"
|
||||||
@ -86,6 +87,13 @@ expected_rte_structs_type_header_content = (
|
|||||||
"void Rte_Write_DUMMY_NVM_LIST_16_DUMMY_NVM_LIST_16(dt_DUMMY_NVM_LIST_16 *block);"
|
"void Rte_Write_DUMMY_NVM_LIST_16_DUMMY_NVM_LIST_16(dt_DUMMY_NVM_LIST_16 *block);"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
expected_calibration_header_content = ""
|
||||||
|
|
||||||
|
expected_calibration_calibration_header_content = (
|
||||||
|
"const dt_mVcSignalOne* Rte_CData_testName_SC_mVcSignalOne(void);\n"
|
||||||
|
"UInt16 Rte_CData_testName_SC_sVcSignalTwo(void);\n"
|
||||||
|
)
|
||||||
|
|
||||||
expected_type_header_footer = "\n#endif /* RTE_TYPE_H */\n"
|
expected_type_header_footer = "\n#endif /* RTE_TYPE_H */\n"
|
||||||
|
|
||||||
expected_source_header = (
|
expected_source_header = (
|
||||||
|
@ -79,7 +79,8 @@ class TestRteDummy(unittest.TestCase):
|
|||||||
rte_dummy.expected_swc_content,
|
rte_dummy.expected_swc_content,
|
||||||
rte_dummy.expected_type_header_header,
|
rte_dummy.expected_type_header_header,
|
||||||
rte_dummy.expected_typedefs,
|
rte_dummy.expected_typedefs,
|
||||||
rte_dummy.expected_type_header_content,
|
rte_dummy.expected_nvm_header_content,
|
||||||
|
rte_dummy.expected_calibration_header_content,
|
||||||
rte_dummy.expected_type_header_footer,
|
rte_dummy.expected_type_header_footer,
|
||||||
rte_dummy.expected_source_header,
|
rte_dummy.expected_source_header,
|
||||||
rte_dummy.expected_nvm_source_content,
|
rte_dummy.expected_nvm_source_content,
|
||||||
@ -100,7 +101,8 @@ class TestRteDummy(unittest.TestCase):
|
|||||||
rte_dummy.expected_swc_content,
|
rte_dummy.expected_swc_content,
|
||||||
rte_dummy.expected_rte_structs_type_header_header,
|
rte_dummy.expected_rte_structs_type_header_header,
|
||||||
rte_dummy.expected_rte_structs_typedefs,
|
rte_dummy.expected_rte_structs_typedefs,
|
||||||
rte_dummy.expected_rte_structs_type_header_content,
|
rte_dummy.expected_rte_structs_nvm_header_content,
|
||||||
|
rte_dummy.expected_calibration_header_content,
|
||||||
rte_dummy.expected_type_header_footer,
|
rte_dummy.expected_type_header_footer,
|
||||||
rte_dummy.expected_source_header,
|
rte_dummy.expected_source_header,
|
||||||
rte_dummy.expected_rte_structs_nvm_source_content,
|
rte_dummy.expected_rte_structs_nvm_source_content,
|
||||||
@ -114,7 +116,7 @@ class TestRteDummy(unittest.TestCase):
|
|||||||
calibration_data = {
|
calibration_data = {
|
||||||
"class_info": {
|
"class_info": {
|
||||||
"mVcSignalOne": {
|
"mVcSignalOne": {
|
||||||
"width": [2, 2],
|
"width": [2, 3],
|
||||||
"type": "UInt16",
|
"type": "UInt16",
|
||||||
"autosar_type": "dt_mVcSignalOne",
|
"autosar_type": "dt_mVcSignalOne",
|
||||||
},
|
},
|
||||||
@ -135,7 +137,8 @@ class TestRteDummy(unittest.TestCase):
|
|||||||
rte_dummy.expected_swc_content,
|
rte_dummy.expected_swc_content,
|
||||||
rte_dummy.expected_rte_structs_type_header_header,
|
rte_dummy.expected_rte_structs_type_header_header,
|
||||||
rte_dummy.expected_rte_structs_and_calibration_typedefs,
|
rte_dummy.expected_rte_structs_and_calibration_typedefs,
|
||||||
rte_dummy.expected_rte_structs_type_header_content,
|
rte_dummy.expected_rte_structs_nvm_header_content,
|
||||||
|
rte_dummy.expected_calibration_calibration_header_content,
|
||||||
rte_dummy.expected_type_header_footer,
|
rte_dummy.expected_type_header_footer,
|
||||||
rte_dummy.expected_source_header,
|
rte_dummy.expected_source_header,
|
||||||
rte_dummy.expected_rte_structs_nvm_source_content,
|
rte_dummy.expected_rte_structs_nvm_source_content,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user