Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically detect zero-cost types #48

Open
pavel-kirienko opened this issue Oct 6, 2020 · 0 comments
Open

Automatically detect zero-cost types #48

pavel-kirienko opened this issue Oct 6, 2020 · 0 comments
Labels

Comments

@pavel-kirienko
Copy link
Member

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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants