From 5b4b0293af886bfd5d2ae8d77755fd2cef6eb4f0 Mon Sep 17 00:00:00 2001 From: Jonathan Diamond Date: Fri, 11 Oct 2024 21:12:11 -0700 Subject: [PATCH] Add flag to platform storage to capture UserConfig platform. --- .../messages/configuration.py | 14 ++++++++++---- .../fusion_engine/messages/configuration.h | 18 ++++++++++++++++-- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/python/fusion_engine_client/messages/configuration.py b/python/fusion_engine_client/messages/configuration.py index 48000249..e8ff9b2b 100644 --- a/python/fusion_engine_client/messages/configuration.py +++ b/python/fusion_engine_client/messages/configuration.py @@ -1772,13 +1772,18 @@ class PlatformStorageDataMessage(MessagePayload): @brief Device storage data response. """ MESSAGE_TYPE = MessageType.PLATFORM_STORAGE_DATA - MESSAGE_VERSION = 2 + MESSAGE_VERSION = 3 + + FLAG_USER_CONFIG_PLATFORM_NOT_SPECIFIED = 0 + FLAG_USER_CONFIG_PLATFORM_POSIX = 1 + FLAG_USER_CONFIG_PLATFORM_EMBEDDED = 2 + FLAG_USER_CONFIG_PLATFORM_EMBEDDED_SSR = 3 PlatformStorageDataMessageConstruct = Struct( "data_type" / AutoEnum(Int8ul, DataType), "response" / AutoEnum(Int8ul, Response), "source" / AutoEnum(Int8ul, ConfigurationSource), - Padding(1), + "flags" / Int8ul, "data_version" / _DataVersionConstruct, "data_length_bytes" / Int32ul, "data" / Bytes(this.data_length_bytes), @@ -1788,6 +1793,7 @@ def __init__(self): self.data_version = DataVersion(0, 0) self.data_type = DataType.INVALID self.response = Response.DATA_CORRUPTED + self.flags = 0 self.source = ConfigurationSource.ACTIVE self.data = bytes() @@ -1805,14 +1811,14 @@ def unpack(self, buffer: bytes, offset: int = 0, message_version: int = MessageP def __repr__(self): result = super().__repr__()[:-1] result += f', response={self.response}, type={self.data_type}, source={self.source}, ' \ - f'version={self.data_version}, size={len(self.data)} B]' + f'flags= {self.flags}, version={self.data_version}, size={len(self.data)} B]' return result def __str__(self): return construct_message_to_string( message=self, construct=self.PlatformStorageDataMessageConstruct, title=f'Platform Storage Data ({str(self.data_type)}, {len(self.data)} B)', - fields=['response', 'source', 'data_version']) + fields=['response', 'source', 'flags', 'data_version']) def calcsize(self) -> int: return len(self.pack()) diff --git a/src/point_one/fusion_engine/messages/configuration.h b/src/point_one/fusion_engine/messages/configuration.h index 191305ee..f0bb4d9c 100644 --- a/src/point_one/fusion_engine/messages/configuration.h +++ b/src/point_one/fusion_engine/messages/configuration.h @@ -1483,11 +1483,24 @@ struct P1_ALIGNAS(4) ExportDataMessage { * - Version 1: Added data_validity field. * - Version 2: Changed data_validity to a @ref Response enum and added * @ref source field. + * - Version 3: Added flags field. */ struct P1_ALIGNAS(4) PlatformStorageDataMessage { static constexpr MessageType MESSAGE_TYPE = MessageType::PLATFORM_STORAGE_DATA; - static constexpr uint8_t MESSAGE_VERSION = 2; + static constexpr uint8_t MESSAGE_VERSION = 3; + + /** + * @ref DataType::USER_CONFIG flag that does not specify what platform the + * configuration corresponds to. + */ + static constexpr uint8_t FLAG_USER_CONFIG_PLATFORM_NOT_SPECIFIED = 0; + /** @ref DataType::USER_CONFIG flag for posix platforms. */ + static constexpr uint8_t FLAG_USER_CONFIG_PLATFORM_POSIX = 1; + /** @ref DataType::USER_CONFIG flag for embedded platforms. */ + static constexpr uint8_t FLAG_USER_CONFIG_PLATFORM_EMBEDDED = 2; + /** @ref DataType::USER_CONFIG flag for embedded SSR platforms. */ + static constexpr uint8_t FLAG_USER_CONFIG_PLATFORM_EMBEDDED_SSR = 3; /** * The type of data contained in this message. @@ -1503,7 +1516,8 @@ struct P1_ALIGNAS(4) PlatformStorageDataMessage { * ConfigurationSource::ACTIVE. */ ConfigurationSource source = ConfigurationSource::ACTIVE; - uint8_t reserved[1] = {0}; + /** @ref DataType specific flags. */ + uint8_t flags = 0; /** Version of data contents. */ DataVersion data_version; /** Number of bytes in data contents. */