OpenCyphal / OpenCyphal/pydsdl

Automatically detect zero-cost types

Open
#48 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

class-feature help wanted priority-high
Dominant language
Python
Stars
13
Forks
11
PR merge metrics
No merged PRs in 30d

Description

On a little-endian IEEE 754-compliant machine the following definition (comments removed) can be (de-)serialized in C/C++ using memcpy (possibly DMA-assisted). In Python, serialization can be delegated to the standard struct module.

truncated uint64 unique_id

uavcan.si.unit.mass.Scalar.1.0 mass

uavcan.si.unit.electric_charge.Scalar.1.0 design_capacity

uavcan.si.unit.voltage.Scalar.1.0[2] design_cell_voltage_min_max

uavcan.si.unit.electric_current.Scalar.1.0 discharge_current
uavcan.si.unit.electric_current.Scalar.1.0 discharge_current_burst
uavcan.si.unit.electric_current.Scalar.1.0 charge_current
uavcan.si.unit.electric_current.Scalar.1.0 charge_current_fast
uavcan.si.unit.electric_current.Scalar.1.0 charge_termination_treshold
uavcan.si.unit.voltage.Scalar.1.0          charge_voltage

uint16 cycle_count

void8
uint8 series_cell_count

uint7 state_of_health_pct
void1

Technology.0.1 technology  # This is an enumeration

This is based on https://forum.uavcan.org/t/future-zero-cost-serialization-constraint/469, but this capability is just an implementation detail that does not require any support from the Specification.

PyDSDL should detect such zero-cost types automatically. Probably it makes sense to express the availability of zero-cost (de-)serialization as a function of platform properties:

  • Zero-cost (de-)serialization is not possible.
  • ZCS is possible for little-endian IEEE 754-compliant platforms with a conventional memory model.
  • ZCS is possible for little-endian platforms with a conventional memory model (when floating point fields are not present).
  • ZCS is possible for any platform with a conventional memory model (when the largest field is not larger than one byte).

Contributor guide

Open the contributing guide

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.

Research direction

No files, tests, or entry points are named in the issue. Start by locating PyDSDL's existing type analysis and serialization-related entry points, then determine how the four platform-property outcomes should be represented and tested; done means zero-cost types are detected automatically for the stated platform constraints.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp, python
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.