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

Parameter System Testing #33

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b31741d
Update `Parameter_Manager` component for testing
Jbsco Aug 22, 2024
e6ff25d
Add COSMOS table validation test
Jbsco Aug 22, 2024
b6fba06
Modify COSMOS table validation test to use a mock table
Jbsco Aug 22, 2024
eea01f3
Include `Update_Parameter_Table` in COSMOS parameter system tests
Jbsco Aug 22, 2024
9b73651
Switch testing from `check_formatted` to `wait_check`
Jbsco Aug 26, 2024
2b86ad4
Import CRC function, calculate length
Jbsco Aug 31, 2024
5c9b2be
Modify COSMOS install script to also copy test scripts
Jbsco Aug 31, 2024
ed678d5
Add validation_status to SW status packet
Jbsco Sep 6, 2024
d64f196
Use `crc_16.py` to apply CRC in COSMOS scripts
Jbsco Sep 6, 2024
fad3e09
Check active parameters using `Dump_Parameters` command
Jbsco Sep 6, 2024
44c9542
Implement checking Active_Parameters CRC and table buffer directly
Jbsco Sep 7, 2024
4ed2995
Add `clear_counts` to `test_setup.py`
Jbsco Sep 10, 2024
69d2779
Index from the beginning for CRC and table_buffer
Jbsco Sep 10, 2024
296686e
Replace `wait_check` with `check` where appropriate
Jbsco Sep 10, 2024
bb3107a
Add checks in validation test for CRC and version
Jbsco Sep 10, 2024
8bc9f2d
Create table records using Adamant type definitions
Jbsco Sep 21, 2024
42948d8
Modify scripts to handle type dependencies for COSMOS test scripts
Jbsco Sep 21, 2024
84d2ca9
Modify setup script to copy crc_16.py from Adamant
Jbsco Sep 21, 2024
b974015
Modify `update-param-sys.py` to use Adamant defs when checking dumped…
Jbsco Sep 22, 2024
4bf8cbf
Remove errant log
Jbsco Sep 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
508 changes: 508 additions & 0 deletions src/assembly/linux/1

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions src/assembly/linux/linux_example.assembly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ components:
set_id_bases:
- "Command_Id_Base => 5200"
init:
- "Parameter_Table_Length => Linux_Example_Parameter_Table.Parameter_Table_Size_In_Bytes"
- "Ticks_Until_Timeout => 3"
########################################
# Telemetry system:
Expand Down Expand Up @@ -1070,9 +1069,17 @@ connections:
to_component: Parameters_Instance
to_connector: Parameters_Memory_Region_T_Recv_Async
- from_component: Parameter_Manager_Instance
from_connector: Default_Parameters_Memory_Region_Send
from_connector: Primary_Parameters_Memory_Region_Send
to_component: Parameter_Store_Instance
to_connector: Parameters_Memory_Region_T_Recv_Async
- from_component: Parameter_Manager_Instance
from_connector: Redundant_Parameters_Memory_Region_Send
to_component: Parameter_Store_Instance
to_connector: Parameters_Memory_Region_T_Recv_Async
- from_component: Parameter_Manager_Instance
from_connector: Data_Product_T_Send
to_component: Product_Database_Instance
to_connector: Data_Product_T_Recv_Sync
- from_component: Parameter_Store_Instance
from_connector: Parameters_Memory_Region_Release_T_Send
to_component: Parameter_Manager_Instance
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
-- Includes:
with Tick;
with Command;
with Configuration;
with Parameter_Manager_Types;
with Parameter_Manager_Table_Header;
with Parameters_Memory_Region_Release;
with Protected_Variables;
with Task_Synchronization;
with Memory_Region;

-- This component is responsible for managing the working, scratch, and default parameter tables. Its sole responsibility is to respond to commands to copy parameter tables from one region to another or to dump the scratch region.
-- This component is responsible for managing a working and default parameter
-- table. Its sole responsibility is to respond to commands to copy parameter
-- tables from one region to another.
package Component.Parameter_Manager.Implementation is

-- The component class instance record:
Expand All @@ -22,10 +26,14 @@ package Component.Parameter_Manager.Implementation is
-- Initialization parameters for the Parameter Manager.
--
-- Init Parameters:
-- parameter_Table_Length : Natural - The size of the parameter table in bytes. This must be known to the component so it can construct correct sized memory regions for the downstream components.
-- ticks_Until_Timeout : Natural - The component will wait until it has received at least this many ticks before reporting a timeout error while waiting for a parameter update/fetch response from either the active or default parameter components. For example, if the component is attached to a 10Hz rate group and this value is set to 7, then the component will wait between 700 and 800 ms before declaring a timeout error from an unresponsive downstream component.
-- Ticks_Until_Timeout : Natural - The component will wait until it has received
-- at least this many ticks before reporting a timeout error while waiting for a
-- parameter update/fetch response from either the working or default parameter
-- components. For example, if the component is attached to a 10Hz rate group and
-- this value is set to 7, then the component will wait between 700 and 800 ms
-- before declaring a timeout error from an unresponsive downstream component.
--
overriding procedure Init (Self : in out Instance; Parameter_Table_Length : in Natural; Ticks_Until_Timeout : in Natural);
overriding procedure Init (Self : in out Instance; Ticks_Until_Timeout : in Natural);

private

Expand All @@ -40,18 +48,6 @@ private
Response : Protected_Parameters_Memory_Region_Release.Variable;
-- Variables used for task synchronization and timeouts:
Sync_Object : Task_Synchronization.Wait_Release_Timeout_Counter_Object;
-- Other configuration:
Parameter_Table_Length : Natural := 0;
-- Temporary storage to allow safe copying between Default and Working.
-- We declare this here, instead of as a temporary variable within a function
-- because if a timeout error occurs, we have no guarantee that the downstream
-- component is not reading/writing from this data. If it is declared here, then
-- at least only this data can be corrupted, and not the stack, which would be
-- a much worse situation. The assembly should be designed that timeout errors
-- never occur in order to fully prevent this issue.
Parameter_Bytes : Basic_Types.Byte_Array_Access;
-- Create a memory region that points to this buffer:
Parameter_Bytes_Region : Memory_Region.T;
end record;

---------------------------------------
Expand All @@ -69,13 +65,17 @@ private
---------------------------------------
-- Invokee connector primitives:
---------------------------------------
-- The component should be attached to a periodic tick that is used to timeout waiting for a parameter update/fetch response. See the ticks_Until_Timeout initialization parameter.
-- The component should be attached to a periodic tick that is used to timeout
-- waiting for a parameter update/fetch response. See the ticks_Until_Timeout
-- initialization parameter.
overriding procedure Timeout_Tick_Recv_Sync (Self : in out Instance; Arg : in Tick.T);
-- The command receive connector.
overriding procedure Command_T_Recv_Async (Self : in out Instance; Arg : in Command.T);
-- This procedure is called when a Command_T_Recv_Async message is dropped due to a full queue.
overriding procedure Command_T_Recv_Async_Dropped (Self : in out Instance; Arg : in Command.T);
-- Parameter update/fetch responses are returned synchronously on this connector. The component waits internally for this response, or times out if the response is not received in time.
-- Parameter update/fetch responses are returned synchronously on this connector.
-- The component waits internally for this response, or times out if the response
-- is not received in time.
overriding procedure Parameters_Memory_Region_Release_T_Recv_Sync (Self : in out Instance; Arg : in Parameters_Memory_Region_Release.T);

---------------------------------------
Expand All @@ -85,20 +85,33 @@ private
overriding procedure Command_Response_T_Send_Dropped (Self : in out Instance; Arg : in Command_Response.T) is null;
-- This procedure is called when a Working_Parameters_Memory_Region_Send message is dropped due to a full queue.
overriding procedure Working_Parameters_Memory_Region_Send_Dropped (Self : in out Instance; Arg : in Parameters_Memory_Region.T) is null;
-- This procedure is called when a Default_Parameters_Memory_Region_Send message is dropped due to a full queue.
overriding procedure Default_Parameters_Memory_Region_Send_Dropped (Self : in out Instance; Arg : in Parameters_Memory_Region.T) is null;
-- This procedure is called when a Primary_Parameters_Memory_Region_Send message is dropped due to a full queue.
overriding procedure Primary_Parameters_Memory_Region_Send_Dropped (Self : in out Instance; Arg : in Parameters_Memory_Region.T) is null;
-- This procedure is called when a Redundant_Parameters_Memory_Region_Send message is dropped due to a full queue.
overriding procedure Redundant_Parameters_Memory_Region_Send_Dropped (Self : in out Instance; Arg : in Parameters_Memory_Region.T) is null;
-- This procedure is called when a Data_Product_T_Send message is dropped due to a full queue.
overriding procedure Data_Product_T_Send_Dropped (Self : in out Instance; Arg : in Data_Product.T) is null;
-- This procedure is called when a Event_T_Send message is dropped due to a full queue.
overriding procedure Event_T_Send_Dropped (Self : in out Instance; Arg : in Event.T) is null;

-----------------------------------------------
-- Command handler primitives:
-----------------------------------------------
-- Description:
-- These are the commands for the Parameter Store component.
-- Copy parameter table from source to destination based on the enumeration provided.
overriding function Copy_Parameter_Table (Self : in out Instance; Arg : in Packed_Parameter_Table_Copy_Type.T) return Command_Execution_Status.E;
-- These are the commands for the Parameter Manager component.
-- Send received parameter table to default and working regions.
overriding function Update_Parameter_Table (Self : in out Instance; Arg : in Packed_Parameter_Table.T) return Command_Execution_Status.E;
-- Validate a received parameter table.
overriding function Validate_Parameter_Table (Self : in out Instance; Arg : in Packed_Parameter_Table.T) return Command_Execution_Status.E;

-- Invalid command handler. This procedure is called when a command's arguments are found to be invalid:
overriding procedure Invalid_Command (Self : in out Instance; Cmd : in Command.T; Errant_Field_Number : in Unsigned_32; Errant_Field : in Basic_Types.Poly_Type);

-- Compile time checks to make sure parameter manager types do not serialize longer than the size of the command buffer minus the parameter table header:
pragma Warnings (Off, "condition can only be True if invalid values present");
pragma Compile_Time_Error (
Configuration.Command_Buffer_Size - Parameter_Manager_Table_Header.Size_In_Bytes /= Parameter_Manager_Types.Parameter_Manager_Buffer_Type'Length,
"Parameter_Manager_Buffer_Length_Type has a maximum size in bytes unequal to the Command_Buffer_Size minus the Parameter_Manager_Table_Header size."
);
pragma Warnings (On, "condition can only be True if invalid values present");
end Component.Parameter_Manager.Implementation;
Binary file modified src/components/parameter_manager/doc/parameter_manager.pdf
Binary file not shown.
25 changes: 25 additions & 0 deletions src/components/parameter_manager/doc/parameter_manager.tex
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,51 @@ \subsection{Diagram}
\subsection{Connectors}
\input{build/tex/parameter_manager_connectors.tex}

\subsection{Interrupts}

\input{build/tex/parameter_manager_interrupts.tex}

\subsection{Initialization}
\input{build/tex/parameter_manager_init.tex}

\subsection{Commands}

\input{build/tex/parameter_manager_commands.tex}

\subsection{Parameters}

\input{build/tex/parameter_manager_parameters.tex}

\subsection{Events}

\input{build/tex/parameter_manager_events.tex}

\subsection{Data Products}

\input{build/tex/parameter_manager_data_products.tex}

\subsection{Data Dependencies}

\input{build/tex/parameter_manager_data_dependencies.tex}

\subsection{Packets}

\input{build/tex/parameter_manager_packets.tex}

\subsection{Faults}

\input{build/tex/parameter_manager_faults.tex}

\section{Unit Tests}

\input{build/tex/parameter_manager_unit_test.tex}

\section{Appendix}

\subsection{Preamble}

\input{build/tex/parameter_manager_preamble.tex}

\subsection{Packed Types}

\input{build/tex/parameter_manager_types.tex}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
description: Generic parameter packet for holding a parameter table
fields:
- name: Header
description: The parameter table header
type: Parameter_Manager_Table_Header.T
- name: Table_Buffer
description: A buffer that contains the parameter table
type: Parameter_Manager_Types.Parameter_Manager_Buffer_Type
format: U8x{{ command_buffer_size - 8 }}
variable_length: Header.Table_Buffer_Length
17 changes: 17 additions & 0 deletions src/components/parameter_manager/packed_validation.record.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
description: A packed validation record
fields:
- name: Last_Validation_Version
description: The version of the most recently validated table.
type: Short_Float
format: F32
- name: Crc_Table
description: The CRC of the most recently validated table.
type: Crc_16.Crc_16_Type
format: U16
skip_validation: True
byte_image: True
- name: Last_Validation_Status
description: The status of the most recent table validation operation.
type: Parameter_Enums.Parameter_Table_Update_Status.E
format: E8
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
description: A packed record which holds the most recently validated parameter table header with its validation status.
fields:
- name: Last_Validation_Header
description: The header of the most recently validated parameter table.
type: Parameter_Manager_Table_Header.T
- name: Last_Validation_Status
description: The status of the most recent table validation operation.
type: Parameter_Enums.Parameter_Table_Update_Status.E
format: E8
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
description: These are the commands for the Parameter Manager component.
commands:
- name: Copy_Parameter_Table
description: Copy parameter table from source to destination based on the enumeration provided.
arg_type: Packed_Parameter_Table_Copy_Type.T
- name: Update_Parameter_Table
description: Send received parameter table to default and working regions.
arg_type: Packed_Parameter_Table.T
- name: Validate_Parameter_Table
description: Validate a received parameter table.
arg_type: Packed_Parameter_Table.T
26 changes: 18 additions & 8 deletions src/components/parameter_manager/parameter_manager.component.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,44 @@ execution: active
init:
description: Initialization parameters for the Parameter Manager.
parameters:
- name: parameter_Table_Length
type: Natural
description: The size of the parameter table in bytes. This must be known to the component so it can construct correct sized memory regions for the downstream components.
- name: ticks_Until_Timeout
- name: Ticks_Until_Timeout
type: Natural
description: The component will wait until it has received at least this many ticks before reporting a timeout error while waiting for a parameter update/fetch response from either the working or default parameter components. For example, if the component is attached to a 10Hz rate group and this value is set to 7, then the component will wait between 700 and 800 ms before declaring a timeout error from an unresponsive downstream component.
connectors:
###################################
# Invokee Connectors
###################################
- description: The component should be attached to a periodic tick that is used to timeout waiting for a parameter update/fetch response. See the ticks_Until_Timeout initialization parameter.
name: Timeout_Tick_Recv_Sync
type: Tick.T
kind: recv_sync
- description: The command receive connector.
type: Command.T
kind: recv_async
- description: Parameter update/fetch responses are returned synchronously on this connector. The component waits internally for this response, or times out if the response is not received in time.
type: Parameters_Memory_Region_Release.T
kind: recv_sync
###################################
# Invoker Connectors
###################################
- description: This connector is used to send the command response back to the command router.
type: Command_Response.T
kind: send
- name: Working_Parameters_Memory_Region_Send
description: Requests to update/fetch the working parameters are made on this connector.
type: Parameters_Memory_Region.T
kind: send
- name: Default_Parameters_Memory_Region_Send
- name: Primary_Parameters_Memory_Region_Send
description: Requests to update/fetch the default parameters are made on this connector.
type: Parameters_Memory_Region.T
kind: send
- description: Parameter update/fetch responses are returned synchronously on this connector. The component waits internally for this response, or times out if the response is not received in time.
type: Parameters_Memory_Region_Release.T
kind: recv_sync
- name: Redundant_Parameters_Memory_Region_Send
description: Requests to update/fetch the default parameters are made on this connector.
type: Parameters_Memory_Region.T
kind: send
- description: The destination for fetched data products to be sent to.
type: Data_Product.T
kind: send
- description: The event send connector
type: Event.T
kind: send
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
description: Data products for the Parameter Manager component
data_products:
- name: Validation_Status
description: The validation status with timestamp and last table ID/version.
type: Packed_Validation.T
16 changes: 14 additions & 2 deletions src/components/parameter_manager/parameter_manager.events.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ description: Events for the Parameter Manager component.
events:
- name: Starting_Parameter_Table_Copy
description: Starting parameter table copy from source to destination.
param_type: Packed_Parameter_Table_Copy_Type.T
param_type: Parameter_Manager_Table_Header.T
- name: Finished_Parameter_Table_Copy
description: Finished parameter table copy from source to destination, without errors.
param_type: Packed_Parameter_Table_Copy_Type.T
param_type: Parameter_Manager_Table_Header.T
- name: Invalid_Command_Received
description: A command was received with invalid parameters.
param_type: Invalid_Command_Info.T
Expand All @@ -15,6 +15,18 @@ events:
- name: Parameter_Table_Copy_Failure
description: A parameter table copy failed.
param_type: Parameters_Memory_Region_Release.T
- name: Working_Table_Update_Failure
description: A parameter table copy to the working table failed.
param_type: Packed_Validation_Header.T
- name: Primary_Table_Update_Failure
description: A parameter table copy to the primary table failed.
param_type: Packed_Validation_Header.T
- name: Command_Dropped
description: A command was dropped due to a full queue.
param_type: Command_Header.T
- name: Table_Validation_Failure
description: A parameter table validation failed.
param_type: Packed_Validation_Header.T
- name: Table_Validation_Success
description: A parameter table validation was successful.
param_type: Packed_Validation_Header.T
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
description: The requirements for the Parameter Manager component are specified below.
requirements:
- text: The component shall copy a parameter table from default to working on command.
- text: The component shall copy a parameter table from working to default on command.
- text: The component shall copy a parameter table from a command payload to default and working regions, on command.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
description: A packed record which holds parameter table header data. This data will be prepended to the table data upon upload.
preamble: |
-- Declare the start index at which to begin calculating the CRC. The
-- start index is dependent on this type, and so is declared here so that
-- it is easier to keep in sync.
Crc_Section_Length : constant Natural := Crc_16.Crc_16_Type'Length;
Version_Length : constant Natural := 4;
fields:
- name: Table_Buffer_Length
description: The length of the parameter table buffer.
type: Parameter_Manager_Types.Parameter_Manager_Buffer_Length_Type
format: U16
- name: Crc_Table
description: The CRC of the parameter table, as computed by a ground system, and uplinked with the table.
type: Crc_16.Crc_16_Type
format: U16
skip_validation: True
byte_image: True
- name: Version
description: The current version of the parameter table.
type: Short_Float
format: F32
13 changes: 13 additions & 0 deletions src/components/parameter_manager/parameter_manager_types.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
with Basic_Types;
with Configuration;

-- Declaration of Parameter Manager types. This ensures that
-- it is NOT just a naked natural, giving the compiler
-- more information to help find errors.
package Parameter_Manager_Types is
-- Length type:
subtype Parameter_Manager_Buffer_Length_Type is Natural range 0 .. Configuration.Command_Buffer_Size - 8;
subtype Parameter_Manager_Buffer_Index_Type is Parameter_Manager_Buffer_Length_Type range 0 .. Parameter_Manager_Buffer_Length_Type'Last - 1;
-- Buffer type:
subtype Parameter_Manager_Buffer_Type is Basic_Types.Byte_Array (Parameter_Manager_Buffer_Index_Type);
end Parameter_Manager_Types;
Loading
Loading