Skip to content

Commit

Permalink
Add flag to platform storage to capture UserConfig platform. (#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
axlan authored Oct 15, 2024
2 parents 22e120f + 1f437d3 commit b8ca122
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
14 changes: 10 additions & 4 deletions python/fusion_engine_client/messages/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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()

Expand All @@ -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())
25 changes: 22 additions & 3 deletions src/point_one/fusion_engine/messages/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -1480,14 +1480,24 @@ struct P1_ALIGNAS(4) ExportDataMessage {
* See also @ref ExportDataMessage.
*
* Changes:
* - Version 1: Added data_validity field.
* - Version 1: Added `data_validity` field.
* - Version 2: Changed data_validity to a @ref Response enum and added
* @ref source field.
* - Version 3: Added @ref 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 field is not set. */
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.
Expand All @@ -1503,7 +1513,16 @@ struct P1_ALIGNAS(4) PlatformStorageDataMessage {
* ConfigurationSource::ACTIVE.
*/
ConfigurationSource source = ConfigurationSource::ACTIVE;
uint8_t reserved[1] = {0};
/**
* @ref DataType specific flags.
*
* Currently, only defined for @ref DataType::USER_CONFIG contents. This value
* can optionally set to one of the `FLAG_USER_CONFIG_PLATFORM_*` values to
* indicate which type of platform the UserConfig is valid for. This value
* can be left at `0` for backwards compatibility or to indicate the platform
* type is unknown.
*/
uint8_t flags = 0;
/** Version of data contents. */
DataVersion data_version;
/** Number of bytes in data contents. */
Expand Down

0 comments on commit b8ca122

Please sign in to comment.