From c54a9bf29b5210a76d39ed1527108bf14f6184e9 Mon Sep 17 00:00:00 2001 From: anirudh-seela <111730234+anirudh-seela@users.noreply.github.com> Date: Tue, 28 Nov 2023 13:08:49 -0800 Subject: [PATCH 1/2] Update nanopb_generator.py --- generator/nanopb_generator.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py index 087a63eda..030fe81cd 100755 --- a/generator/nanopb_generator.py +++ b/generator/nanopb_generator.py @@ -414,6 +414,8 @@ def __init__(self, names, desc, enum_options, element_path, comments): # by definition, `names` include this enum's name base_name = Names(names.parts[-1]) + if str(Names(names.parts[:-1])) == "osi3_Lane_Classification": + base_name = "LCT_" if enum_options.long_names: self.values = [(names + x.name, x.number) for x in desc.value] From 3199bbe11abb38746e801a0577b8450b1991d08d Mon Sep 17 00:00:00 2001 From: anirudh-seela <111730234+anirudh-seela@users.noreply.github.com> Date: Tue, 28 Nov 2023 13:21:52 -0800 Subject: [PATCH 2/2] Added explanation as a comment --- generator/nanopb_generator.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py index 030fe81cd..71d1eddfa 100755 --- a/generator/nanopb_generator.py +++ b/generator/nanopb_generator.py @@ -413,6 +413,9 @@ def __init__(self, names, desc, enum_options, element_path, comments): self.names = names # by definition, `names` include this enum's name + # This truncation to only take the last part of the enum name is to allow npb structs to be exported as external C types in Simulink, which have a character restriction limit. + # However, in some cases like in the osi_lane proto, the truncated enum members could be identical across different enums causing symbol clash issues. + # As such, we handle those cases like below explicitly to avoid symbol clashing by renaming these members slightly. base_name = Names(names.parts[-1]) if str(Names(names.parts[:-1])) == "osi3_Lane_Classification": base_name = "LCT_"