Skip to main content

Commands

Command Definition Files

Command definition files define the command packets that can be sent to COSMOS targets. One large file can be used to define the command packets, or multiple files can be used at the user's discretion. Command definition files are placed in the target's cmd_tlm directory and are processed alphabetically. Therefore if you have some command files that depend on others, e.g. they override or extend existing commands, they must be named last. The easiest way to do this is to add an extension to an existing file name. For example, if you already have cmd.txt you can create cmd_override.txt for commands that depends on the definitions in cmd.txt. Also note that due to the way the ASCII Table is structured, files beginning with capital letters are processed before lower case letters.

When defining command parameters you can choose from the following data types: INT, UINT, FLOAT, STRING, BLOCK. These correspond to integers, unsigned integers, floating point numbers, strings and binary blocks of data. The only difference between a STRING and BLOCK is when COSMOS reads the binary command log it stops reading a STRING type when it encounters a null byte (0). This shows up in the text log produced by Data Extractor. Note that this does NOT affect the data COSMOS writes as it's still legal to pass null bytes (0) in STRING parameters.

Command Keywords

COMMAND

Defines a new command packet

ParameterDescriptionRequired
TargetName of the target this command is associated withTrue
CommandName of this command. Also referred to as its mnemonic. Must be unique to commands to this target. Ideally will be as short and clear as possible.True
EndiannessIndicates if the data in this command is to be sent in Big Endian or Little Endian format

Valid Values: BIG_ENDIAN, LITTLE_ENDIAN
True
DescriptionDescription of this command which must be enclosed with quotesFalse

Example Usage:

COMMAND INST COLLECT BIG_ENDIAN "Start collect"

COMMAND Modifiers

The following keywords must follow a COMMAND keyword.

PARAMETER

Defines a command parameter in the current command packet

ParameterDescriptionRequired
NameName of the parameter. Must be unique within the command.True
Bit OffsetBit offset into the command packet of the Most Significant Bit of this parameter. May be negative to indicate on offset from the end of the packet. Always use a bit offset of 0 for derived parameters.True
Bit SizeBit size of this parameter. Zero or Negative values may be used to indicate that a string fills the packet up to the offset from the end of the packet specified by this value. If Bit Offset is 0 and Bit Size is 0 then this is a derived parameter and the Data Type must be set to 'DERIVED'.True
Data TypeData Type of this parameter

Valid Values: INT, UINT, FLOAT, DERIVED, STRING, BLOCK
True

When Data Type is INT, UINT, FLOAT, DERIVED the remaining parameters are:

ParameterDescriptionRequired
Minimum ValueMinimum allowed value for this parameterTrue
Maximum ValueMaximum allowed value for this parameterTrue
Default ValueDefault value for this parameter. You must provide a default but if you mark the parameter REQUIRED then scripts will be forced to specify a value.True
DescriptionDescription for this parameter which must be enclosed with quotesFalse
EndiannessIndicates if the data in this command is to be sent in Big Endian or Little Endian format. See guide on Little Endian Bitfields.

Valid Values: BIG_ENDIAN, LITTLE_ENDIAN
False

When Data Type is STRING, BLOCK the remaining parameters are:

ParameterDescriptionRequired
Default ValueDefault value for this parameter. You must provide a default but if you mark the parameter REQUIRED then scripts will be forced to specify a value.True
DescriptionDescription for this parameter which must be enclosed with quotesFalse
EndiannessIndicates if the data in this command is to be sent in Big Endian or Little Endian format

Valid Values: BIG_ENDIAN, LITTLE_ENDIAN
False

Example Usage:

PARAMETER SYNC 0 32 UINT 0xDEADBEEF 0xDEADBEEF 0xDEADBEEF "Sync pattern"
PARAMETER DATA 32 32 INT MIN MAX 0 "Data value"
PARAMETER VALUE 64 32 FLOAT 0 10.5 2.5
PARAMETER LABEL 96 96 STRING "OPENC3" "The label to apply"
PARAMETER BLOCK 192 0 BLOCK 0x0 "Block of binary data"

PARAMETER Modifiers

The following keywords must follow a PARAMETER keyword.

FORMAT_STRING

Adds printf style formatting

ParameterDescriptionRequired
FormatHow to format using printf syntax. For example, '0x%0X' will display the value in hex.True

Example Usage:

FORMAT_STRING "0x%0X"

UNITS

Add displayed units

ParameterDescriptionRequired
Full NameFull name of the units type, e.g. CelsiusTrue
AbbreviatedAbbreviation for the units, e.g. CTrue

Example Usage:

UNITS Celsius C
UNITS Kilometers KM

DESCRIPTION

Override the defined description

ParameterDescriptionRequired
ValueThe new descriptionTrue

META

Stores custom user metadata

Meta data is user specific data that can be used by custom tools for various purposes. One example is to store additional information needed to generate source code header files.

ParameterDescriptionRequired
Meta NameName of the metadata to storeTrue
Meta ValuesOne or more values to be stored for this Meta NameFalse

Example Usage:

META TEST "This parameter is for test purposes only"

OVERLAP

(Since 4.4.1)
This item is allowed to overlap other items in the packet

If an item's bit offset overlaps another item, OpenC3 issues a warning. This keyword explicitly allows an item to overlap another and suppresses the warning message.

KEY

(Since 5.0.10)
Defines the key used to access this raw value in the packet.

Keys are often JsonPath or XPath strings

ParameterDescriptionRequired
Key stringThe key to access this itemTrue

Example Usage:

KEY $.book.title

VARIABLE_BIT_SIZE

(Since 5.18.0)
Marks an item as having its bit size defined by another length item

ParameterDescriptionRequired
Length Item NameThe name of the associated length itemTrue
Length Bits Per CountBits per count of the length item. Defaults to 8False
Length Value Bit OffsetOffset in Bits to Apply to Length Field Value. Defaults to 0False

REQUIRED

Parameter is required to be populated in scripts

When sending the command via Script Runner a value must always be given for the current command parameter. This prevents the user from relying on a default value. Note that this does not affect Command Sender which will still populate the field with the default value provided in the PARAMETER definition.

MINIMUM_VALUE

Override the defined minimum value

ParameterDescriptionRequired
ValueThe new minimum value for the parameterTrue

MAXIMUM_VALUE

Override the defined maximum value

ParameterDescriptionRequired
ValueThe new maximum value for the parameterTrue

DEFAULT_VALUE

Override the defined default value

ParameterDescriptionRequired
ValueThe new default value for the parameterTrue

STATE

Defines a key/value pair for the current command parameter

Key value pairs allow for user friendly strings. For example, you might define states for ON = 1 and OFF = 0. This allows the word ON to be used rather than the number 1 when sending the command parameter and allows for much greater clarity and less chance for user error.

ParameterDescriptionRequired
KeyThe string state nameTrue
ValueThe numerical state valueTrue
Hazardous / Disable MessagesIndicates the state is hazardous. This will cause a popup to ask for user confirmation when sending this command. For non-hazardous states you can also set DISABLE_MESSAGES which will not print the command when using that state.

Valid Values: HAZARDOUS
False
Hazardous DescriptionString describing why this state is hazardousFalse

Example Usage:

APPEND_PARAMETER ENABLE 32 UINT 0 1 0 "Enable setting"
STATE FALSE 0
STATE TRUE 1
APPEND_PARAMETER STRING 1024 STRING "NOOP" "String parameter"
STATE "NOOP" "NOOP" DISABLE_MESSAGES
STATE "ARM LASER" "ARM LASER" HAZARDOUS "Arming the laser is an eye safety hazard"
STATE "FIRE LASER" "FIRE LASER" HAZARDOUS "WARNING! Laser will be fired!"

WRITE_CONVERSION

Applies a conversion when writing the current command parameter

Conversions are implemented in a custom Ruby or Python file which should be located in the target's lib folder. The class must inherit from Conversion. It must implement the initialize (Ruby) or __init__ (Python) method if it takes extra parameters and must always implement the call method. The conversion factor is applied to the value entered by the user before it is written into the binary command packet and sent.

Multiple write conversions on command parameters

When a command is built, each item gets written (and write conversions are run) to set the default value. Then items are written (again write conversions are run) with user provided values. Thus write conversions can be run twice. Also there are no guarantees which parameters have already been written. The packet itself has a given_values() method which can be used to retrieve a hash of the user provided values to the command. That can be used to check parameter values passed in.

ParameterDescriptionRequired
Class FilenameThe filename which contains the Ruby or Python class. The filename must be named after the class such that the class is a CamelCase version of the underscored filename. For example, 'the_great_conversion.rb' should contain 'class TheGreatConversion'.True
ParameterAdditional parameter values for the conversion which are passed to the class constructor.False

Ruby Example:

WRITE_CONVERSION the_great_conversion.rb 1000

Defined in the_great_conversion.rb:

require 'openc3/conversions/conversion'
module OpenC3
class TheGreatConversion < Conversion
def initialize(multiplier)
super()
@multiplier = multiplier.to_f
end
def call(value, packet, buffer)
return value * multiplier
end
end
end

Python Example:

WRITE_CONVERSION the_great_conversion.py 1000

Defined in the_great_conversion.py:

from openc3.conversions.conversion import Conversion
class TheGreatConversion(Conversion):
def __init__(self, multiplier):
super().__init__()
self.multiplier = float(multiplier)
def call(self, value, packet, buffer):
return value * multiplier

POLY_WRITE_CONVERSION

Adds a polynomial conversion factor to the current command parameter

The conversion factor is applied to the value entered by the user before it is written into the binary command packet and sent.

ParameterDescriptionRequired
C0CoefficientTrue
CxAdditional coefficient values for the conversion. Any order polynomial conversion may be used so the value of 'x' will vary with the order of the polynomial. Note that larger order polynomials take longer to process than shorter order polynomials, but are sometimes more accurate.False

Example Usage:

POLY_WRITE_CONVERSION 10 0.5 0.25

SEG_POLY_WRITE_CONVERSION

Adds a segmented polynomial conversion factor to the current command parameter

This conversion factor is applied to the value entered by the user before it is written into the binary command packet and sent.

ParameterDescriptionRequired
Lower BoundDefines the lower bound of the range of values that this segmented polynomial applies to. Is ignored for the segment with the smallest lower bound.True
C0CoefficientTrue
CxAdditional coefficient values for the conversion. Any order polynomial conversion may be used so the value of 'x' will vary with the order of the polynomial. Note that larger order polynomials take longer to process than shorter order polynomials, but are sometimes more accurate.False

Example Usage:

SEG_POLY_WRITE_CONVERSION 0 10 0.5 0.25 # Apply the conversion to all values < 50
SEG_POLY_WRITE_CONVERSION 50 11 0.5 0.275 # Apply the conversion to all values >= 50 and < 100
SEG_POLY_WRITE_CONVERSION 100 12 0.5 0.3 # Apply the conversion to all values >= 100

GENERIC_WRITE_CONVERSION_START

Start a generic write conversion

Adds a generic conversion function to the current command parameter. This conversion factor is applied to the value entered by the user before it is written into the binary command packet and sent. The conversion is specified as Ruby or Python code that receives two implied parameters. 'value' which is the raw value being written and 'packet' which is a reference to the command packet class (Note, referencing the packet as 'myself' is still supported for backwards compatibility). The last line of code should return the converted value. The GENERIC_WRITE_CONVERSION_END keyword specifies that all lines of code for the conversion have been given.

Multiple write conversions on command parameters

When a command is built, each item gets written (and write conversions are run) to set the default value. Then items are written (again write conversions are run) with user provided values. Thus write conversions can be run twice. Also there are no guarantees which parameters have already been written. The packet itself has a given_values() method which can be used to retrieve a hash of the user provided values to the command. That can be used to check parameter values passed in.

warning

Generic conversions are not a good long term solution. Consider creating a conversion class and using WRITE_CONVERSION instead. WRITE_CONVERSION is easier to debug and higher performance.

Ruby Example:

APPEND_PARAMETER ITEM1 32 UINT 0 0xFFFFFFFF 0
GENERIC_WRITE_CONVERSION_START
return (value * 1.5).to_i # Convert the value by a scale factor
GENERIC_WRITE_CONVERSION_END

Python Example:

APPEND_PARAMETER ITEM1 32 UINT 0 0xFFFFFFFF 0
GENERIC_WRITE_CONVERSION_START
return int(value * 1.5) # Convert the value by a scale factor
GENERIC_WRITE_CONVERSION_END

GENERIC_WRITE_CONVERSION_END

Complete a generic write conversion

OVERFLOW

Set the behavior when writing a value overflows the type

By default OpenC3 throws an error if you try to write a value which overflows its specified type, e.g. writing 255 to a 8 bit signed value. Setting the overflow behavior also allows for OpenC3 to 'TRUNCATE' the value by eliminating any high order bits. You can also set 'SATURATE' which causes OpenC3 to replace the value with the maximum or minimum allowable value for that type. Finally you can specify 'ERROR_ALLOW_HEX' which will allow for a maximum hex value to be written, e.g. you can successfully write 255 to a 8 bit signed value.

ParameterDescriptionRequired
BehaviorHow OpenC3 treats an overflow value. Only applies to signed and unsigned integer data types.

Valid Values: ERROR, ERROR_ALLOW_HEX, TRUNCATE, SATURATE
True

Example Usage:

OVERFLOW TRUNCATE

APPEND_PARAMETER

Defines a command parameter in the current command packet

ParameterDescriptionRequired
NameName of the parameter. Must be unique within the command.True
Bit SizeBit size of this parameter. Zero or Negative values may be used to indicate that a string fills the packet up to the offset from the end of the packet specified by this value. If Bit Offset is 0 and Bit Size is 0 then this is a derived parameter and the Data Type must be set to 'DERIVED'.True
Data TypeData Type of this parameter

Valid Values: INT, UINT, FLOAT, DERIVED, STRING, BLOCK
True

When Data Type is INT, UINT, FLOAT, DERIVED the remaining parameters are:

ParameterDescriptionRequired
Minimum ValueMinimum allowed value for this parameterTrue
Maximum ValueMaximum allowed value for this parameterTrue
Default ValueDefault value for this parameter. You must provide a default but if you mark the parameter REQUIRED then scripts will be forced to specify a value.True
DescriptionDescription for this parameter which must be enclosed with quotesFalse
EndiannessIndicates if the data in this command is to be sent in Big Endian or Little Endian format. See guide on Little Endian Bitfields.

Valid Values: BIG_ENDIAN, LITTLE_ENDIAN
False

When Data Type is STRING, BLOCK the remaining parameters are:

ParameterDescriptionRequired
Default ValueDefault value for this parameter. You must provide a default but if you mark the parameter REQUIRED then scripts will be forced to specify a value.True
DescriptionDescription for this parameter which must be enclosed with quotesFalse
EndiannessIndicates if the data in this command is to be sent in Big Endian or Little Endian format

Valid Values: BIG_ENDIAN, LITTLE_ENDIAN
False

Example Usage:

APPEND_PARAMETER SYNC 32 UINT 0xDEADBEEF 0xDEADBEEF 0xDEADBEEF "Sync pattern"
APPEND_PARAMETER VALUE 32 FLOAT 0 10.5 2.5
APPEND_PARAMETER LABEL 0 STRING "OPENC3" "The label to apply"

ID_PARAMETER

Defines an identification command parameter in the current command packet

ID parameters are used to identify the binary block of data as a particular command. A command packet may have one or more ID_PARAMETERs and all must match the binary data for the command to be identified.

ParameterDescriptionRequired
NameName of the parameter. Must be unique within the command.True
Bit OffsetBit offset into the command packet of the Most Significant Bit of this parameter. May be negative to indicate on offset from the end of the packet.True
Bit SizeBit size of this parameter. Zero or Negative values may be used to indicate that a string fills the packet up to the offset from the end of the packet specified by this value. If Bit Offset is 0 and Bit Size is 0 then this is a derived parameter and the Data Type must be set to 'DERIVED'.True
Data TypeData Type of this parameter

Valid Values: INT, UINT, FLOAT, DERIVED, STRING, BLOCK
True

When Data Type is INT, UINT, FLOAT, DERIVED the remaining parameters are:

ParameterDescriptionRequired
Minimum ValueMinimum allowed value for this parameterTrue
Maximum ValueMaximum allowed value for this parameterTrue
ID ValueIdentification value for this parameter. The binary data must match this value for the buffer to be identified as this packet.True
DescriptionDescription for this parameter which must be enclosed with quotesFalse
EndiannessIndicates if the data in this command is to be sent in Big Endian or Little Endian format. See guide on Little Endian Bitfields.

Valid Values: BIG_ENDIAN, LITTLE_ENDIAN
False

When Data Type is STRING, BLOCK the remaining parameters are:

ParameterDescriptionRequired
Default ValueDefault value for this parameter. You must provide a default but if you mark the parameter REQUIRED then scripts will be forced to specify a value.True
DescriptionDescription for this parameter which must be enclosed with quotesFalse
EndiannessIndicates if the data in this command is to be sent in Big Endian or Little Endian format

Valid Values: BIG_ENDIAN, LITTLE_ENDIAN
False

Example Usage:

ID_PARAMETER OPCODE 32 32 UINT 2 2 2 "Opcode identifier"

APPEND_ID_PARAMETER

Defines an identification command parameter in the current command packet

ID parameters are used to identify the binary block of data as a particular command. A command packet may have one or more ID_PARAMETERs and all must match the binary data for the command to be identified.

ParameterDescriptionRequired
NameName of the parameter. Must be unique within the command.True
Bit SizeBit size of this parameter. Zero or Negative values may be used to indicate that a string fills the packet up to the offset from the end of the packet specified by this value. If Bit Offset is 0 and Bit Size is 0 then this is a derived parameter and the Data Type must be set to 'DERIVED'.True
Data TypeData Type of this parameter

Valid Values: INT, UINT, FLOAT, DERIVED, STRING, BLOCK
True

When Data Type is INT, UINT, FLOAT, DERIVED the remaining parameters are:

ParameterDescriptionRequired
Minimum ValueMinimum allowed value for this parameterTrue
Maximum ValueMaximum allowed value for this parameterTrue
ID ValueIdentification value for this parameter. The binary data must match this value for the buffer to be identified as this packet.True
DescriptionDescription for this parameter which must be enclosed with quotesFalse
EndiannessIndicates if the data in this command is to be sent in Big Endian or Little Endian format. See guide on Little Endian Bitfields.

Valid Values: BIG_ENDIAN, LITTLE_ENDIAN
False

When Data Type is STRING, BLOCK the remaining parameters are:

ParameterDescriptionRequired
Default ValueDefault value for this parameter. You must provide a default but if you mark the parameter REQUIRED then scripts will be forced to specify a value.True
DescriptionDescription for this parameter which must be enclosed with quotesFalse
EndiannessIndicates if the data in this command is to be sent in Big Endian or Little Endian format

Valid Values: BIG_ENDIAN, LITTLE_ENDIAN
False

Example Usage:

APPEND_ID_PARAMETER OPCODE 32 UINT 2 2 2 "Opcode identifier"

ARRAY_PARAMETER

Defines a command parameter in the current command packet that is an array

ParameterDescriptionRequired
NameName of the parameter. Must be unique within the command.True
Bit OffsetBit offset into the command packet of the Most Significant Bit of this parameter. May be negative to indicate on offset from the end of the packet. Always use a bit offset of 0 for derived parameters.True
Item Bit SizeBit size of each array itemTrue
Item Data TypeData Type of each array item

Valid Values: INT, UINT, FLOAT, STRING, BLOCK, DERIVED
True
Array Bit SizeTotal Bit Size of the Array. Zero or Negative values may be used to indicate the array fills the packet up to the offset from the end of the packet specified by this value.True
DescriptionDescription which must be enclosed with quotesFalse
EndiannessIndicates if the data is to be sent in Big Endian or Little Endian format

Valid Values: BIG_ENDIAN, LITTLE_ENDIAN
False

Example Usage:

ARRAY_PARAMETER ARRAY 64 64 FLOAT 640 "Array of 10 64bit floats"

APPEND_ARRAY_PARAMETER

Defines a command parameter in the current command packet that is an array

ParameterDescriptionRequired
NameName of the parameter. Must be unique within the command.True
Item Bit SizeBit size of each array itemTrue
Item Data TypeData Type of each array item

Valid Values: INT, UINT, FLOAT, STRING, BLOCK, DERIVED
True
Array Bit SizeTotal Bit Size of the Array. Zero or Negative values may be used to indicate the array fills the packet up to the offset from the end of the packet specified by this value.True
DescriptionDescription which must be enclosed with quotesFalse
EndiannessIndicates if the data is to be sent in Big Endian or Little Endian format

Valid Values: BIG_ENDIAN, LITTLE_ENDIAN
False

Example Usage:

APPEND_ARRAY_PARAMETER ARRAY 64 FLOAT 640 "Array of 10 64bit floats"

SELECT_PARAMETER

Selects an existing command parameter for editing

Must be used in conjunction with SELECT_COMMAND to first select the packet. Typically used to override generated values or make specific changes to commands that only affect a particular instance of a target used multiple times.

ParameterDescriptionRequired
ParameterName of the parameter to select for modificationTrue

Example Usage:

SELECT_COMMAND INST COLLECT
SELECT_PARAMETER DURATION
# Add units
UNITS Seconds S

DELETE_PARAMETER

(Since 4.4.1)
Deletes an existing command parameter from the packet definition

Deleting a parameter from the command definition does not remove the defined space for that parameter. Thus unless you redefine a new parameter, there will be a "hole" in the packet where the data is not accessible. You can use SELECT_COMMAND and then PARAMETER to define a new parameter.

ParameterDescriptionRequired
ParameterName of the parameter to deleteTrue

Example Usage:

SELECT_COMMAND INST COLLECT
DELETE_PARAMETER DURATION

HIDDEN

Hides this command from all OpenC3 tools such as Command Sender and Handbook Creator

Hidden commands do not appear in the Script Runner popup helper when writing scripts. The command still exists in the system and can be sent by scripts.

DISABLED

Disables this command from being sent

Hides the command and also disables it from being sent by scripts. Attempts to send DISABLED commands result in an error message.

DISABLE_MESSAGES

Disable the Server from printing cmd(...) messages. Commands are still logged.

META

Stores metadata for the current command

Meta data is user specific data that can be used by custom tools for various purposes. One example is to store additional information needed to generate source code header files.

ParameterDescriptionRequired
Meta NameName of the metadata to storeTrue
Meta ValuesOne or more values to be stored for this Meta NameFalse

Example Usage:

META FSW_TYPE "struct command"

HAZARDOUS

Designates the current command as hazardous

Sending a hazardous command causes a dialog asking for confirmation before sending the command

ParameterDescriptionRequired
DescriptionDescription for why the command is hazardous which must be enclosed with quotesFalse

ACCESSOR

(Since 5.0.10)
Defines the class used to read and write raw values from the packet

Defines the class that is used too read raw values from the packet. Defaults to BinaryAccessor. Provided accessors also include JsonAccessor, CborAccessor, HtmlAccessor, and XmlAccessor.

ParameterDescriptionRequired
Accessor Class NameThe name of the accessor classTrue
ArgumentAdditional argument passed to the accessor class constructorFalse

TEMPLATE

(Since 5.0.10)
Defines a template string used to initialize the command before default values are filled in

Generally the template string is formatted in JSON or HTML and then values are filled in with command parameters. Must be UTF-8 encoded.

ParameterDescriptionRequired
TemplateThe template string which should be enclosed in quotesTrue

TEMPLATE_FILE

(Since 5.0.10)
Defines a template file used to initialize the command before default values are filled in

Generally the template file is formatted in JSON or HTML and then values are filled in with command parameters. Can be binary or UTF-8.

ParameterDescriptionRequired
Template File PathThe relative path to the template file. Filename should generally start with an underscore.True

RESPONSE

(Since 5.14.0)
Indicates the expected telemetry packet response to this command

ParameterDescriptionRequired
Target NameTarget Name of telemetry response packetTrue
Packet NamePacket Name of telemetry response packetTrue

ERROR_RESPONSE

(Since 5.14.0)
Indicates the expected telemetry packet error response to this command

ParameterDescriptionRequired
Target NameTarget Name of telemetry error response packetTrue
Packet NamePacket Name of telemetry error response packetTrue

(Since 5.14.0)
Defines a related telemetry item to this command

ParameterDescriptionRequired
Target NameTarget Name of related telemetry itemTrue
Packet NamePacket Name of related telemetry itemTrue
Item NameItem Name of related telemetry itemTrue

SCREEN

(Since 5.14.0)
Defines a related telemetry screen to this command

ParameterDescriptionRequired
Target NameTarget Name of related telemetry screenTrue
Screen NameScreen Name of related telemetry screenTrue

VIRTUAL

(Since 5.18.0)
Marks this packet as virtual and not participating in identification

Used for packet definitions that can be used as structures for items with a given packet.

RESTRICTED

(Since 5.20.0)
Marks this packet as restricted and will require approval if critical commanding is enabled

Used as one of the two types of critical commands (HAZARDOUS and RESTRICTED)

VALIDATOR

(Since 5.19.0)
Defines a validator class for a command

Validator class is used to validate the command success or failure with both a pre_check and post_check method.

ParameterDescriptionRequired
Class FilenameThe filename which contains the Ruby or Python class. The filename must be named after the class such that the class is a CamelCase version of the underscored filename. For example, 'command_validator.rb' should contain 'class CommandValidator'.True
ArgumentAdditional argument passed to the validator class constructorFalse

Ruby Example:

VALIDATOR custom_validator.rb

Defined in custom_validator.rb:

require 'openc3/packets/command_validator'
class CustomValidator < OpenC3::CommandValidator
def pre_check(packet)
if tlm("TGT PKT ITEM") == 0
return [false, "TGT PKT ITEM is 0"]
end
@cmd_acpt_cnt = tlm("TGT PKT CMD_ACPT_CNT")
return [true, nil]
end
def post_check(packet)
wait_check("TGT PKT CMD_ACPT_CNT > #{@cmd_acpt_cnt}", 10)
return [true, nil]
end
end

Python Example:

VALIDATOR custom_validator.rb

Defined in custom_validator.py:

class CustomValidator(CommandValidator):
def pre_check(self, command):
if tlm("TGT PKT ITEM") == 0:
return [False, "TGT PKT ITEM is 0"]
self.cmd_acpt_cnt = tlm("INST HEALTH_STATUS CMD_ACPT_CNT")
return [True, None]

def post_check(self, command):
wait_check(f"INST HEALTH_STATUS CMD_ACPT_CNT > {self.cmd_acpt_cnt}", 10)
return [True, None]

SELECT_COMMAND

Selects an existing command packet for editing

Typically used in a separate configuration file from where the original command is defined to override or add to the existing command definition. Must be used in conjunction with SELECT_PARAMETER to change an individual parameter.

ParameterDescriptionRequired
Target NameName of the target this command is associated withTrue
Command NameName of the command to selectTrue

Example Usage:

SELECT_COMMAND INST COLLECT
SELECT_PARAMETER DURATION
# Add units
UNITS Seconds S

Example File

Example File: TARGET/cmd_tlm/cmd.txt

COMMAND TARGET COLLECT_DATA BIG_ENDIAN "Commands my target to collect data"
PARAMETER CCSDSVER 0 3 UINT 0 0 0 "CCSDS PRIMARY HEADER VERSION NUMBER"
PARAMETER CCSDSTYPE 3 1 UINT 1 1 1 "CCSDS PRIMARY HEADER PACKET TYPE"
PARAMETER CCSDSSHF 4 1 UINT 0 0 0 "CCSDS PRIMARY HEADER SECONDARY HEADER FLAG"
ID_PARAMETER CCSDSAPID 5 11 UINT 0 2047 100 "CCSDS PRIMARY HEADER APPLICATION ID"
PARAMETER CCSDSSEQFLAGS 16 2 UINT 3 3 3 "CCSDS PRIMARY HEADER SEQUENCE FLAGS"
PARAMETER CCSDSSEQCNT 18 14 UINT 0 16383 0 "CCSDS PRIMARY HEADER SEQUENCE COUNT"
PARAMETER CCSDSLENGTH 32 16 UINT 4 4 4 "CCSDS PRIMARY HEADER PACKET LENGTH"
PARAMETER ANGLE 48 32 FLOAT -180.0 180.0 0.0 "ANGLE OF INSTRUMENT IN DEGREES"
POLY_WRITE_CONVERSION 0 0.01745 0 0
PARAMETER MODE 80 8 UINT 0 1 0 "DATA COLLECTION MODE"
STATE NORMAL 0
STATE DIAG 1
COMMAND TARGET NOOP BIG_ENDIAN "Do Nothing"
PARAMETER CCSDSVER 0 3 UINT 0 0 0 "CCSDS PRIMARY HEADER VERSION NUMBER"
PARAMETER CCSDSTYPE 3 1 UINT 1 1 1 "CCSDS PRIMARY HEADER PACKET TYPE"
PARAMETER CCSDSSHF 4 1 UINT 0 0 0 "CCSDS PRIMARY HEADER SECONDARY HEADER FLAG"
ID_PARAMETER CCSDSAPID 5 11 UINT 0 2047 101 "CCSDS PRIMARY HEADER APPLICATION ID"
PARAMETER CCSDSSEQFLAGS 16 2 UINT 3 3 3 "CCSDS PRIMARY HEADER SEQUENCE FLAGS"
PARAMETER CCSDSSEQCNT 18 14 UINT 0 16383 0 "CCSDS PRIMARY HEADER SEQUENCE COUNT"
PARAMETER CCSDSLENGTH 32 16 UINT 0 0 0 "CCSDS PRIMARY HEADER PACKET LENGTH"
PARAMETER DUMMY 48 8 UINT 0 0 0 "DUMMY PARAMETER BECAUSE CCSDS REQUIRES 1 BYTE OF DATA"
COMMAND TARGET SETTINGS BIG_ENDIAN "Set the Settings"
PARAMETER CCSDSVER 0 3 UINT 0 0 0 "CCSDS PRIMARY HEADER VERSION NUMBER"
PARAMETER CCSDSTYPE 3 1 UINT 1 1 1 "CCSDS PRIMARY HEADER PACKET TYPE"
PARAMETER CCSDSSHF 4 1 UINT 0 0 0 "CCSDS PRIMARY HEADER SECONDARY HEADER FLAG"
ID_PARAMETER CCSDSAPID 5 11 UINT 0 2047 102 "CCSDS PRIMARY HEADER APPLICATION ID"
PARAMETER CCSDSSEQFLAGS 16 2 UINT 3 3 3 "CCSDS PRIMARY HEADER SEQUENCE FLAGS"
PARAMETER CCSDSSEQCNT 18 14 UINT 0 16383 0 "CCSDS PRIMARY HEADER SEQUENCE COUNT"
PARAMETER CCSDSLENGTH 32 16 UINT 0 0 0 "CCSDS PRIMARY HEADER PACKET LENGTH"
<% 5.times do |x| %>
APPEND_PARAMETER SETTING<%= x %> 16 UINT 0 5 0 "Setting <%= x %>"
<% end %>