Skip to content

Commit 7538242

Browse files
authored
Use correct enum size when generating tlm packet structures (#4333)
* Use correct enum size when generating tlm packet structures (#4261) Instead of hardcoding enums as 4 bytes, the enum size should be parsed from the topology XML. * Override CI configuration to use appropriate settings and target refs for v3.6 builds
1 parent 5a3b873 commit 7538242

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

.github/workflows/build-test-rpi.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jobs:
5858
- uses: actions/checkout@v4
5959
with:
6060
sparse-checkout: 'requirements.txt'
61+
sparse-checkout-cone-mode: false
6162
- name: "Setup environment"
6263
run: |
6364
python -m venv venv

.github/workflows/cookiecutters-test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ jobs:
2626
uses: ./.github/workflows/reusable-get-pr-branch.yml
2727
with:
2828
target_repository: nasa/fprime-tools
29+
default_target_ref: v3.6.1
2930

3031
get-bootstrap-branch:
3132
name: "Get fprime-bootstrap target branch"
3233
uses: ./.github/workflows/reusable-get-pr-branch.yml
3334
with:
3435
target_repository: nasa/fprime-bootstrap
36+
default_target_ref: v1.4.0
3537

3638
# -------- Install target versions of the cookiecutter templates and validate -------
3739
Validate:

.github/workflows/ext-build-hello-world.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
uses: ./.github/workflows/reusable-get-pr-branch.yml
2121
with:
2222
target_repository: fprime-community/fprime-tutorial-hello-world
23+
default_target_ref: v3.6.0
2324

2425
run:
2526
needs: get-branch

.github/workflows/ext-build-led-blinker.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
uses: ./.github/workflows/reusable-get-pr-branch.yml
2121
with:
2222
target_repository: fprime-community/fprime-workshop-led-blinker
23+
default_target_ref: v3.6.0
2324

2425
run:
2526
needs: get-branch

.github/workflows/ext-build-math-comp.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
uses: ./.github/workflows/reusable-get-pr-branch.yml
2121
with:
2222
target_repository: fprime-community/fprime-tutorial-math-component
23+
default_target_ref: v3.6.0
2324

2425
run:
2526
needs: get-branch

.github/workflows/ext-raspberry-led-blinker.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
uses: ./.github/workflows/reusable-get-pr-branch.yml
2525
with:
2626
target_repository: fprime-community/fprime-workshop-led-blinker
27+
default_target_ref: v3.6.0
2728

2829
cross-compilation:
2930
name: "Cross Compilation"
@@ -74,6 +75,7 @@ jobs:
7475
uses: actions/checkout@v4
7576
with:
7677
sparse-checkout: 'requirements.txt'
78+
sparse-checkout-cone-mode: false
7779
- name: "Setup environment"
7880
run: |
7981
python -m venv venv

Autocoders/Python/bin/tlm_packet_gen.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,11 @@ def generate_channel_size_dict(self, the_parsed_topology_xml, xml_filename):
224224
if self.verbose:
225225
print("Processing Channel %s" % channel_name)
226226
chan_type = chan.get_type()
227-
# if channel is enum
228-
if type(chan_type) == type(tuple()):
229-
chan_size = 4
230227
# if channel type is string
231228
# elif chan_type == "string":
232229
# chan_size = int(chan.get_size()) + 2 # FIXME: buffer size storage size magic number - needs to be turned into a constant
233230
# if channel is serializable
234-
elif chan_type in self.size_dict:
231+
if chan_type in self.size_dict:
235232
chan_size = self.size_dict[chan_type]
236233
else:
237234
chan_size = self.get_type_size(chan_type, chan.get_size())
@@ -506,10 +503,7 @@ def process_serializable_files(self, serializable_file_list):
506503
member_comment,
507504
_,
508505
) in serializable_model.get_members():
509-
# if enumeration
510-
if type(member_type) == type(tuple()):
511-
type_size = 4 # Fixme: can we put this in a constant somewhere?
512-
elif (
506+
if (
513507
member_type in self.size_dict.keys()
514508
): # See if it is a registered type
515509
type_size = self.size_dict[member_type]
@@ -536,9 +530,9 @@ def process_enum_files(self, enum_file_list):
536530
enum_file = search_for_file("Enumeration", enum_file)
537531
enum_model = XmlEnumParser.XmlEnumParser(enum_file)
538532
enum_type = enum_model.get_namespace() + "::" + enum_model.get_name()
539-
self.add_type_size(
540-
enum_type, 4
541-
) # Fixme: can we put this in a constant somewhere?
533+
serialize_type = enum_model.get_serialize_type()
534+
enum_size = self.get_type_size(serialize_type, None)
535+
self.add_type_size(enum_type, enum_size)
542536

543537
def process_array_files(self, array_file_list):
544538
for array_file in array_file_list:
@@ -552,9 +546,7 @@ def process_array_files(self, array_file_list):
552546
array_size = int(array_model.get_size())
553547
elem_type = array_model.get_type()
554548
elem_type_size = None
555-
if type(elem_type) == type(tuple()):
556-
elem_type_size = 4 # Fixme: can we put this in a constant somewhere?
557-
elif elem_type in self.size_dict.keys(): # See if it is a registered type
549+
if elem_type in self.size_dict.keys(): # See if it is a registered type
558550
elem_type_size = self.size_dict[elem_type]
559551
else:
560552
elem_type_size = self.get_type_size(elem_type, 1) # Fixme: strings?

0 commit comments

Comments
 (0)