Running a Command Conditionally in a CommandList

A structure for conditional_information contains the reasons for conditional values. The software reason and hardware reason will be defined by an enum and will have a special value. This special value will mean that the command is unconditional on that ‘reason’.

Each command struct in a resource file contains a value of LLINK that is called conditional_information. When loading a command list the resource file reader makes a decision based upon the value of the conditional_information which can either be '0' or a nonzero value.

Follow the steps given below to run a command conditionally in a comamandList:


  1. STRUCT SSM_START_PROCESS_INFO struct in a resource file initiates the process as shown in the code snippet:
    
    STRUCT SSM_START_PROCESS_INFO                     // For starting processes
    {
        WORD type = EStartupProcess;                  // Must not be changed
        LTEXT path = "";                              // Value required
        LTEXT args = "";                              // Passed to the command line of the started process
        WORD start_method = EFireAndForget;           // Can also be EWaitForStart or EDeferredWaitForStart
        LONG timeout = 0;                             // In milliseconds, only used for EWaitForStart
        WORD fail_on_error = EPanicOnCommandFailure;  // Can be EIgnoreCommandFailure
        WORD no_of_retries_on_failure = 0;            // Only used for EWaitForStart
        LLINK conditional_information = 0;            // By default, commands are unconditional
    }

  2. Set the LLINK conditional_information parameter to any value.

    1. If LLINK conditional_information is 0, then the resource file reader adds the command to the CommandList.

    2. If LLINK conditional_information is nonzero, then the resource file reader reads the resource which points to a HBufC, and calls a callback function provided by the policy.

  3. A callback function is passed to the resource file reader by the policy plug-in calls the resource-file reader. The function that is called has a prototype similar to:
    TBool ConditionalCommandAllowedL( HBufC* information );
    If the return value of this function is true then the command is added to the command list by the resource file reader, else it is discarded.

The command is run conditionally in a CommandList.