Skip to content
intrepidcsPublic

About

ICS Protocol Buffers

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

65 Commits

Folders and files

Repository files navigation

icspb

Description

This repository contains protobufs leveraging nanopb intended for device communication and settings storage

Usage

Generating C/C++ source files

The source files for the protobufs are intended to be generated using the nanopb_generator.py Python script found in the nanopb Github repository. This repository contains a script proto_gen.py that can be used to generate the output as a pre-build step for a project to keep the output in sync with the proto definitions.

DeviceSettings options (deny-by-default)

protos/settings/device/v1/device_settings.options.base ignores all DeviceSettings / nested-group fields. device_settings.options is not committed. scripts/merge_device_settings_options.cmake writes it from .base plus an explicit opt-in: -DPORT= for port/<device>/settings_options/device_settings.options, or -DTEMPLATE= for device_settings.options.template. Neither path is implied. With no -DPORT and no -DTEMPLATE, the merge writes deny-all .base only, so a device that forgot its options file fails at compile instead of enabling every field. Unit tests pass the all-in template as -DPORT (or -DTEMPLATE) on purpose. scripts/apply_device_settings_options.cmake does the same when NANOPB_DEVICE_SETTINGS_OPTIONS_PORT is set, and leaves the merge deny-all when that variable is unset.

Adding a new DeviceSettings field

  1. Define the field in the relevant .proto under protos/settings/device/v1/ (or add a new message and wire it into device_settings.proto).
  2. Pick the field number — use an unused tag in that message (gaps are fine if you plan to fill them later). Use reserved only when retiring a number for good (e.g. after deleting a field that may still appear on the wire), so it cannot be reused accidentally.
  3. Opt in for all-in / unit-test builds — add a line to device_settings.options.template with type:FT_DEFAULT (and max_count / fixed_count for repeated fields). max_count alone does not clear FT_IGNORE.
  4. Opt in per device when ready — add the same style of line as in template to that product’s port/<device>/settings_options/device_settings.options (max_count / fixed_count might be different). Until then, deny-by-default keeps the field out of that device’s generated DeviceSettings struct.
  5. Regenerate nanopb outputs (device build or bare nanopb_generator) and update migration / firmware that consume the new field.

Notes:

  • New top-level DeviceSettings.* members and fields under deny-listed groups (DeviceSettingsCANGroup.*, DeviceSettingsEthernetGroup.*, DeviceSettingsLINGroup.*, DeviceSettingsSerdesGroup.*) need explicit opt-ins in steps 3–4.
  • Fields added inside an already opted-in nested message (for example a new member of DeviceSettingsEthernet) appear automatically once that parent is enabled; they do not need a separate DeviceSettings.* options line unless you introduce a new group message covered by the deny wildcards.

Packing

The protobuf parser must know how many bytes to process in order to correctly deserialize the message. This is how each protobuf should be packaged

  1. varint encoded byte length of the following header
  2. SettingsHeader message
  3. Protobuf described in the SettingsHeader

Authors and acknowledgment

Show your appreciation to those who have contributed to the project.

License

protobuf license: https://github.com/protocolbuffers/protobuf/blob/main/LICENSE nanopb license: https://github.com/nanopb/nanopb/blob/master/LICENSE.txt

About

ICS Protocol Buffers

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages