Skip to content

Commit

Permalink
Add flag to platform storage to capture UserConfig platform.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Diamond committed Oct 12, 2024
1 parent 22e120f commit 8b25197
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 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())
18 changes: 16 additions & 2 deletions src/point_one/fusion_engine/messages/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
constexpr uint8_t FLAG_USER_CONFIG_PLATFORM_NOT_SPECIFIED = 0;
/** @ref DataType::USER_CONFIG flag for posix platforms. */
constexpr uint8_t FLAG_USER_CONFIG_PLATFORM_POSIX = 1;
/** @ref DataType::USER_CONFIG flag for embedded platforms. */
constexpr uint8_t FLAG_USER_CONFIG_PLATFORM_EMBEDDED = 2;
/** @ref DataType::USER_CONFIG flag for embedded SSR platforms. */
constexpr uint8_t FLAG_USER_CONFIG_PLATFORM_EMBEDDED_SSR = 3;

/**
* The type of data contained in this message.
Expand All @@ -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. */
Expand Down

0 comments on commit 8b25197

Please sign in to comment.