Skip to content

Automatically detect zero-cost types #48

@pavel-kirienko

Description

@pavel-kirienko

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).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions