Add an option to disable float64 from the generated code

Open
#235 6 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
38/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
cpp, python

Research direction

Start by reading the code generator’s templates and the existing handling of omit_float_serialization_support; the issue does not name specific files or tests. Check how generated code handles unsupported float types and how transpiler options are tested. Done means separate float32 and float64 omission options work, the legacy option remains compatible, and generation errors only when messages use an unsupported type.

Written by the indexing model from the issue text.

Description

feature

Hello! I suggest to add an option to disable sections with float64 from the generated code. Because this type is very bulky for some microcontrollers. It is desirable to enter the same option for float32, because some chips can only work with integer arithmetic.

It seems too strict a restriction to stop compilation by assert in cases where the compiler does not support float32 or float64. It is enough to exclude the corresponding sections of the code if the corresponding float type is not supported by the compiler. For example, using conditional compilation:

#if NUNAVUT_PLATFORM_IEEE754_FLOAT == false
   code with float32...
#endif
#if NUNAVUT_PLATFORM_IEEE754_DOUBLE == false
   code with float64...
#endif

If there are no fields with the floatXX type in the messages, which is not supported by the compiler, then there will be no errors during code generation. If the user wants to generate a code for messages with floatXX, an error will be issued.

Conditional compilation is quite compatible with transpiller options:

{% if not options.omit_float_serialization_support %}
    #if NUNAVUT_PLATFORM_IEEE754_FLOAT == false
        section of code with float32...
    #endif
{% endif -%}

But I would add two more options: omit_float32_serialization_support and omit_float64_serialization_support. The old omit_float_serialization_support option can be left for compatibility.

Dominant language
Python
Stars
48
Forks
26
Avg merge
1d 18h
Merged PRs (30d)
9

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenCyphal/nunavut

All issues in OpenCyphal/nunavut

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.