Logo
Telescience Resource Kit
TReK Python  5.4.0 ART
Packet Class Reference

This class describes a packet composed of one or more parameters. More...

Inherits PacketItem.

Public Member Functions

Initialize / Finalize

Functions handling class initialization and finalization.

def Packet ( Optional[Packet] packet=None -> None ) -> def 
 Class initializer. More...
 
def clone ( -> Packet ) -> def 
 Creates a new instance of the object with the same contents.
 
def copy (copy_from: object -> None ) -> def 
 Copies the contents of the provided 'copy_from' Packet. More...
 
def initialize ( -> None ) -> def 
 Initializes the object. More...
 
def load_file (filename: str -> None ) -> def 
 Loads the Packet definition from the specified file. More...
 
def save_file (filename: str -> None ) -> def 
 Saves the Packet definition to the specified file. More...
 
def get_packet_type ( -> str ) -> def 
 Gets the packet type. More...
 
def set_packet_type (new_type: str -> None ) -> def 
 Sets the packet type. More...
 
Build/Extract
def build (buffer: bytearray -> int ) -> def 
 Builds the packet and places it in the provided buffer. More...
 
def extract (buffer: bytearray, input_length: int -> int ) -> def 
 Extracts all of the parameters in the packet from the specified buffer. More...
 
Parameters

Functions handling parameters.

def add_identifier (name: str, id_info: IdentifierInfo -> None ) -> def 
 Adds an identifier to the packet. More...
 
def clear_all_parameter_values ( -> None ) -> def 
 Clears each parameter value in the packet. More...
 
def clear_checksum_parameter ( -> None ) -> def 
 Turns off checksum parameter calculation when calling build().
 
def clear_counter_parameter ( -> None ) -> def 
 Turns off counter generation when calling build().
 
def clear_length_parameter ( -> None ) -> def 
 Turns off length calculation when calling build().
 
def clear_sequence_flags_parameter ( -> None ) -> def 
 Removes the seqeuence flags parameter reference from the packet.
 
def clear_timestamp_parameter ( -> None ) -> def 
 Turns off time stamp generation when calling build().
 
def find_last_parameter (name: str -> Parameter ) -> def 
 Finds the specified parameter name in the packet. More...
 
def find_parameter (name: str -> Parameter ) -> def 
 Finds the specified parameter name in the packet. More...
 
def get_checksum_parameter ( -> str ) -> def 
 Returns the name of the parameter that is used for the checksum of the packet. More...
 
def get_checksum_parameter_info ( -> ChecksumParameterInfo ) -> def 
 Gets the checksum parameter's attributes. More...
 
def get_counter_parameter ( -> str ) -> def 
 Returns the name of the parameter that is used for the counter of the packet. More...
 
def get_counter_parameter_info ( -> CounterParameterInfo ) -> def 
 Gets the counter parameter's associated attributes. More...
 
def get_fully_qualified_names (name: str -> list[str] ) -> def 
 Gets all of the fully qualified names for a given parameter name within a packet. More...
 
def get_identifier_info (name: str -> IdentifierInfo ) -> def 
 Retrieves the attributes associated with the named identifier. More...
 
def get_identifier_list (recursive: bool=True -> list[str] ) -> def 
 Gets a list of the parameter names used as identifiers. More...
 
def get_length_parameter ( -> str ) -> def 
 Returns the name of the parameter that is used for the length of the packet. More...
 
def get_length_parameter_info ( -> LengthParameterInfo ) -> def 
 Gets the length parameter's attributes. More...
 
def get_parameter_list (full_name: bool=True, mod_only: bool=False -> list[str] ) -> def 
 Returns a list of all parameters within the packet. More...
 
def get_polynomial_info ( -> Optional[ChecksumPolynomialInfo] ) -> def 
 Gets CRC32 Generic information. More...
 
def get_sequence_flags_parameter ( -> str ) -> def 
 Returns the name of the parameter that is used for the sequence flags of the packet. More...
 
def get_sequence_flags_parameter_info ( -> SequenceFlagParameterInfo ) -> def 
 Gets the sequence flags parameter's attributes. More...
 
def get_sorted_parameter_list (full_name: bool=True, mod_only: bool=False -> list[str] ) -> def 
 Returns a sorted list of all parameters within a collection by their start location. More...
 
def get_timestamp_parameter ( -> str ) -> def 
 Returns the name of the parameter that is used for the time stamp of the packet. More...
 
def get_timestamp_parameter_info ( -> TimeStampParameterInfo ) -> def 
 Gets the time stamp parameter's attributes. More...
 
def update_expected_value (name: str, new_value: int -> None ) -> def 
 Updates the expected value for an identifier. More...
 
def set_checksum_parameter (param_name: str, param_info: ChecksumParameterInfo, Optional[ChecksumPolynomialInfo] poly_info=None -> None ) -> def 
 Sets the checksum parameter for the packet. More...
 
def set_counter_parameter (param_name: str, param_info: CounterParameterInfo -> def ) -> def 
 Sets the counter parameter for the packet. More...
 
def set_modifiable_flag_for_all_parameters (new_value: bool -> None ) -> def 
 Sets the modifiable flag for all parameters currently in the packet. More...
 
def set_length_parameter (param_name: str, param_info: LengthParameterInfo -> None ) -> def 
 Sets the length parameter for the packet. More...
 
def set_sequence_flags_parameter (param_name: str, param_info: SequenceFlagParameterInfo -> None ) -> def 
 Sets the sequence flags parameter for the packet. More...
 
def set_timestamp_parameter (param_name: str, param_info: TimeStampParameterInfo -> None ) -> def 
 Sets the time stamp parameter for the packet. More...
 
Packet Collection

Functions handling adding / removing packets.

def add_data (packet_item: PacketItem -> None ) -> def 
 Sets the specified packet item as the data for the packet. More...
 
def add_header (packet_item: PacketItem -> None ) -> def 
 Sets the specified packet item as the header for the packet. More...
 
def add_trailer (packet_item: PacketItem -> None ) -> def 
 Sets the specified packet item as the trailer for the packet. More...
 
def clear_global_packet_map ( -> None ) -> def 
 Removes all parameters from the global packet map. More...
 
def create_global_packet_map ( -> None ) -> def 
 Creates the map used to hold all of the parameters. More...
 
def get_header_length_in_bits ( -> int ) -> def 
 Gets the length of the header in bits. More...
 
def get_header_length_in_bytes ( -> int ) -> def 
 Gets the length of the header in bytes. More...
 
def get_length_in_bits ( -> int ) -> def 
 Gets the length of the packet in bits. More...
 
def get_length_in_bytes ( -> int ) -> def 
 Gets the length of the packet in bytes. More...
 
def get_maximum_length_in_bits ( -> int ) -> def 
 Returns the maximum length of the Packet in bits. More...
 
def get_validation_errors ( -> str ) -> def 
 Gets a string of the last validation errors. More...
 
def has_checksum_error ( -> bool ) -> def 
 Determines if the last packet extraction had a checksum error. More...
 
def has_data_zone ( -> bool ) -> def 
 Determines if the packet has a data zone. More...
 
def has_header_zone ( -> bool ) -> def 
 Determines if the packet has a header zone. More...
 
def has_length_error ( -> bool ) -> def 
 Determines if the last packet extraction had a length error. More...
 
def has_modifiable_data (data_zone_only: bool=True -> bool ) -> def 
 Determines if the packet has any modifiable data. More...
 
def has_trailer_zone ( -> bool ) -> def 
 Determines if the packet has a trailer zone. More...
 
def has_variable_length_data ( -> bool ) -> def 
 Determines if the parameter collection has any variable length data. More...
 
def is_complete ( -> bool ) -> def 
 Determines if the packet definition is considered complete. More...
 
def is_modifiable (top_level: bool=True -> bool ) -> def 
 Determines if any of the data is modifiable. More...
 
def remove_all_identifiers ( -> None ) -> def 
 Removes all identifiers from the packet. More...
 
def remove_identifier (name: str -> None ) -> def 
 Removes the specified parameter as an identifier. More...
 
def remove_trailer ( -> None ) -> def 
 Removes the trailer zone from the packet. More...
 
def remove_data ( -> None ) -> def 
 Removes the data zone from the packet. More...
 
def remove_header ( -> None ) -> def 
 Removes the header zone from the packet. More...
 
def set_timestamp_offset (offset: float -> None ) -> def 
 Sets an offset for the current system time to use when building packets. More...
 
def validate ( -> int ) -> def 
 Validates that the data contained in the packet is logically correct. More...
 
Printing

Functions handling printing.

def print_definition (include_value: bool=False -> str ) -> def 
 Returns a string with basic information about all parameters in the packet. More...
 
def print_packet (buffer: bytearray -> str ) -> def 
 This method is used to print all of the headers in the packet and a hexidecimal representation of the packet contents. More...
 
def print_values ( -> str ) -> def 
 Returns a string with the value of all parameters in the packet.
 
Parameters

Functions handling Parameters.

Packet

Functions handling Packets.

- Public Member Functions inherited from NamedItem
def remove_all_attributes ( -> None ) -> def 
 Removes all attributes.
 
def remove_attribute (name: str -> None ) -> def 
 Removes the attribute by name. More...
 
def __eq__ (named_item: object -> bool ) -> def 
 Equality operator "==". More...
 
def add_attribute (name: str, value: str -> None ) -> def 
 Adds an attribute to the item. More...
 
def get_alias ( -> str ) -> def 
 Returns the alias of the item. More...
 
def get_attribute (name: str -> str ) -> def 
 Get the value of the specified attribute. More...
 
def get_attribute_list ( -> list[str] ) -> def 
 Gets a list of the attribute names. More...
 
def get_name ( -> str ) -> def 
 Returns the name of the item. More...
 
def get_long_description ( -> str ) -> def 
 Returns the long description of the item. More...
 
def get_short_description ( -> str ) -> def 
 Returns the short description of the item. More...
 
def get_user_description ( -> str ) -> def 
 Returns the user description of the item. More...
 
def get_owner ( -> str ) -> def 
 Returns the owner of the item. More...
 
def get_path ( -> str ) -> def 
 Returns the path for the item. More...
 
def set_name (name: str -> None ) -> def 
 Sets the name of the item. More...
 
def set_alias (alias: str -> None ) -> def 
 Sets the alias of the item. More...
 
def set_short_description (description: str -> None ) -> def 
 Sets the short description of the item. More...
 
def set_long_description (description: str -> None ) -> def 
 Sets the long description of the item. More...
 
def set_user_description (description: str -> None ) -> def 
 Sets the user description of the item. More...
 
def set_owner (owner: str -> None ) -> def 
 Sets the owner of the item. More...
 
def set_path (path: str -> None ) -> def 
 Sets the path of the item. More...
 

Detailed Description

This class describes a packet composed of one or more parameters.

The Packet class encapsulates one or more parameters that can be built or extracted. The Packet class has three zones: header, data, and trailer. For the Packet to be considered valid, at least one zone must be populated. Each zone can be populated with a ParameterCollection or another Packet. The example below shows a packet that has all three zones populated. The Header and Trailer zones consist of a parameter collection and the Data zone consists of another Packet which only has two zones populated (Header and Data).

Constructor & Destructor Documentation

◆ Packet()

(packet : Optional[Packet]  ) -> None

Class initializer.

Parameters
[in]packet(Optional) Packet to copy. By default, initializes a new instance.

Reimplemented from NamedItem.

Member Function Documentation

◆ add_data()

(packet_item : PacketItem ) -> None

Sets the specified packet item as the data for the packet.

A copy of the input is made. Any changes made to the input after being added will not be part of the packet unless the data is removed using remove_data() and the changes are added again. The global packet map is cleared as part of this method.

Parameters
[in]packet_itemThe Packet or ParameterCollection to use as the data.
Exceptions
TrekError15028 - TREK_DATA_ZONE_ALREADY_EXISTS

◆ add_header()

(packet_item : PacketItem ) -> None

Sets the specified packet item as the header for the packet.

A copy of the input is made. Any changes made to the input after being added will not be part of the packet unless the header is removed using remove_header() and the changes are added again. The global packet map is cleared as part of this method.

Parameters
[in]packet_itemThe Packet or ParameterCollection to use as the header.
Exceptions
TrekError15028 - TREK_DATA_ZONE_ALREADY_EXISTS

◆ add_identifier()

(name : str 
id_info : IdentifierInfo 
) -> None

Adds an identifier to the packet.

The identifiers are set by build() and will override any data set by a user.

Parameters
[in]nameThe name of the parameter to use as the identifier.
[in]id_infoIdentifier attributes.
Note
IdentifierInfo.parent_start_bit is ignored input (only a return value).
Exceptions
TrekError15005 - TREK_DATA_ALREADY_EXISTS,

15007 - TREK_DATA_DOES_NOT_EXIST

◆ add_trailer()

(packet_item : PacketItem ) -> None

Sets the specified packet item as the trailer for the packet.

A copy of the input is made. Any changes made to the input after being added will not be part of the trailer unless the header is removed using remove_trailer() and the changes are added again. The global packet map is cleared as part of this method.

Parameters
[in]packet_itemThe Packet or ParameterCollection to use as the trailer.

◆ build()

(buffer : bytearray ) -> int

Builds the packet and places it in the provided buffer.

The parameters composing the packet are built and placed in the buffer. After building the parameters, the length, time stamp, counter, and checksum parameters are set if specified. Since nesting of packets is allowed (packet within a packet). The innermost packet is built first.

Parameters
[out]bufferBuffer to contain the composed packet.
Returns
The last bit used if successful.
Exceptions
TrekError15029 - TREK_DATA_ERROR_BUILDING_HEADER_ZONE,

15030 - TREK_DATA_ERROR_BUILDING_DATA_ZONE,

15031 - TREK_DATA_ERROR_BUILDING_TRAILER_ZONE,

15032 - TREK_DATA_NOT_ENOUGH_SPACE,

15034 - TREK_DATA_ERROR_BUILDING_LEN_PARAM,

15049 - TREK_DATA_NEG_LEN_ERROR,

15036 - TREK_DATA_ERROR_BUILDING_COUNTER_PARAM,

15037 - TREK_DATA_ERROR_BUILDING_TIME_PARAM,

15057 - TREK_DATA_ERROR_BUILDING_IDENTIFIER,

15038 - TREK_DATA_ERROR_BUILDING_CHECKSUM_PARAM

◆ clear_all_parameter_values()

() -> None

Clears each parameter value in the packet.

This will prevent the build() from succeeding.

◆ clear_global_packet_map()

() -> None

Removes all parameters from the global packet map.

If parameters are added after CreateGlobalPacketMap is called, this method should be called and the global packet map recreated with another call to create_global_packet_map().

◆ copy()

(copy_from : object ) -> None

Copies the contents of the provided 'copy_from' Packet.

Parameters
[in]copy_fromPacket to copy from.
Exceptions
TypeErrorif 'copy_from' is not a Packet.

Reimplemented from NamedItem.

◆ create_global_packet_map()

() -> None

Creates the map used to hold all of the parameters.

The parameters composing the packet are stored in a map for quick lookup. After all of the data has been added to the packet, this method should be called to build the map.

◆ extract()

(buffer : bytearray 
input_length : int 
) -> int

Extracts all of the parameters in the packet from the specified buffer.

Loops through all of the parameters contained in the packet and extracts their indiviual values (see Parameter for details on what parameter extraction encompasses). If a checksum parameter is defined, the checksum for the buffer is checked to ensure that the data is not corrupt. If the checksum does not match, the data is still extracted. An error will be returned indicating that there is a checksum error. The ParameterStatus associated with any get_value calls for a Parameter will have the Data Quality Checksum Error set to indicate that the value may be bad.

Parameters
[in,out]bufferThe buffer from which to extract.
[in]input_lengthThe valid number of bits that can be read.
Returns
The last bit used, if successful.
Exceptions
TrekError15051 - TREK_DATA_NO_PARENT,

15053 - TREK_DATA_EXT_NUM_SAMP_EXTRACT_FAIL,

15002 - TREK_DATA_EXT_NUM_SAMP_PARAM_NOT_FOUND,

15058 - TREK_DATA_EXT_STATUS_PARAM_NOT_FOUND,

15054 - TREK_DATA_EXT_NUM_SAMP_BAD_VALUE,

15052 - TREK_DATA_EXT_NUM_SAMP_VALUE_FAIL,

15008 - TREK_DATA_INVALID_DATA_TYPE,

15012 - TREK_DATA_INVALID_BYTE_ORDER,

15008 - TREK_DATA_INVALID_DATA_TYPE,

15096 - TREK_DATA_PACKET_LENGTH_ERROR

◆ find_last_parameter()

(name : str ) -> Parameter

Finds the specified parameter name in the packet.

This method will return the last parameter successfully extracted in the packet. If multiple parameters are stored in a packet (e.g., the same parameter exists in multiple formats), this is the method to use to get the current value. It is used by all TReK Telemetry API calls.

Parameters
[in]nameThe name of the parameter to find.
Returns
New parameter object associated with the parameter.
Exceptions
TrekError15007 - TREK_DATA_DOES_NOT_EXIST

◆ find_parameter()

(name : str ) -> Parameter

Finds the specified parameter name in the packet.

Parameters are stored in a map with two names. The short name (the actual name is the Parameter class) and a fully qualified name which includes the packet hierarchy. If two or more parameters have the same name, you must use the fully qualified name to find the packet. Otherwise, either name will work. The fully qualified names for a given parameter an be found in get_fully_qualified_names().

Parameters
[in]nameThe name of the parameter to find.
Returns
Parameter.
Exceptions
TrekError15007 - TREK_DATA_DOES_NOT_EXIST,

15033 - TREK_DATA_MORE_THAN_ONE_PARAMETER

Reimplemented from PacketItem.

◆ get_checksum_parameter()

() -> str

Returns the name of the parameter that is used for the checksum of the packet.

A blank name indicates that the checksum parameter has not been set. If the returned value is not blank, then the checksum attributes associated with the parameter can be retrieved using get_checksum_parameter_info().

Returns
Name of checksum parameter or "" if not in use.

◆ get_checksum_parameter_info()

Gets the checksum parameter's attributes.

Retrieves the zone (header, data, trailer) where the checksum parameter can be found, the start count for the parameter, the direction of the count, the minimum count value the maximum count value, and its parent's start bit. Details about the counter parameter can be retrieved with find_parameter().

Returns
ChecksumParameterInfo containing packet location information for Checksum Parameter.
Exceptions
TrekError15007 - TREK_DATA_DOES_NOT_EXIST

◆ get_counter_parameter()

() -> str

Returns the name of the parameter that is used for the counter of the packet.

A blank name indicates that the counter parameter has not been set. If the returned value is not blank, then the counter attributes associated with the parameter can be retrieved using get_counter_parameter_info().

Returns
Name of counter parameter or "" if not in use.

◆ get_counter_parameter_info()

Gets the counter parameter's associated attributes.

Retrieves the zone (header, data, trailer) where the counter parameter can be found, the start count for the parameter, the direction of the count, the minimum count value the maximum count value, and its parent's start bit. Details about the counter parameter can be retrieved with find_parameter().

Note
If there is not a counter parameter associated with this packet, the function will return the outermost counter associated with any subpackets.
Returns
Data class containing parameter packet location information.

◆ get_fully_qualified_names()

(name : str ) -> list[str]

Gets all of the fully qualified names for a given parameter name within a packet.

Fully qualified names are required to be used when mulitple parameters exist with the same name within a packet. This is most likely to happen when a common parameter name such as "Length" is used more than once. For example, a packet encapsulating another packet may each have a "Length" parameter. It is suggested that more explicit names be used where possible (e.g., "CCSDSLength").

Parameters
[in]nameThe name of the parameter.
Returns
list[str] containing the fully qualified names of all parameters in the packet.

◆ get_header_length_in_bits()

() -> int

Gets the length of the header in bits.

Calculates the length of the header in bits by determining the last bit used by any parameter in the header. create_global_packet_map() must be called before this method will work.

Returns
The length in bits.
Exceptions
TrekError15056 - TREK_DATA_MISSING_ZONE

◆ get_header_length_in_bytes()

() -> int

Gets the length of the header in bytes.

Calculates the length of the header in bits by determining the last bit used by any parameter in the header. create_global_packet_map() must be called before this method will work.

Returns
The length in bytes.
Exceptions
TrekError15056 - TREK_DATA_MISSING_ZONE

◆ get_identifier_info()

(name : str ) -> IdentifierInfo

Retrieves the attributes associated with the named identifier.

For the specified identifier the following information is retrieved: the zone (header, data, trailer) where it can be found, the type of identifier, when or not it has a default value, the default value, whether or not it has an expected value, the expected value , and its parent's start bit. Details about the identifier parameter can be retrieved with find_parameter().

Parameters
[in]nameThe name of the parameter used as the identifier.
Returns
IndentifierInfo attributes information.
Exceptions
TrekError15007 - TREK_DATA_DOES_NOT_EXIST

◆ get_identifier_list()

(recursive : bool  ) -> list[str]

Gets a list of the parameter names used as identifiers.

The parameter names returned are identified by their short name. It is possible for the same name to appear multiple times. get_fully_qualified_names() can be used to get the detailed name of the parameter to resolve conflicts. If no identifiers are available.

Parameters
[in]recursiveIf search includes sub-packets.
Returns
list[str] of parameter names.

◆ get_length_in_bits()

() -> int

Gets the length of the packet in bits.

Calculates the length of the packet in bits by determining the last bit used by any parameter in the packet. create_global_packet_map() must be called before this method will work. The packet must have a fixed length or it will fail.

Returns
Length in bits.
Exceptions
TrekError15017 - TREK_DATA_FIXED_LENGTH_REQUIRED

Reimplemented from PacketItem.

◆ get_length_in_bytes()

() -> int

Gets the length of the packet in bytes.

Calculates the length of the packet in bytes by determining the last byte used by any parameter in the packet. create_global_packet_map() must be called before this method will work. The packet must have a fixed length or it will fail.

Returns
Length in bytes.
Exceptions
TrekError15017 - TREK_DATA_FIXED_LENGTH_REQUIRED

Reimplemented from PacketItem.

◆ get_length_parameter()

() -> str

Returns the name of the parameter that is used for the length of the packet.

A blank name indicates that the length parameter has not been set. If the returned value is not blank, then the length attributes associated with the parameter can be retrieved using get_length_parameter_info().

Returns
Name of length parameter of "" if not in use.

◆ get_length_parameter_info()

Gets the length parameter's attributes.

Retrieves the zone (header, data, trailer) where it the length parameter can be found, the offset associated with the length, and its parent's start bit. Details about the length parameter can be retrieved with find_parameter().

Note
If there is not a length parameter associated with this packet, the function will return the outermost length associated with any subpackets.
Returns
Data class containing length packet location information.
Exceptions
TrekError15007 - TREK_DATA_DOES_NOT_EXIST

◆ get_maximum_length_in_bits()

() -> int

Returns the maximum length of the Packet in bits.

If the Packet has variable length data, the actual length may be less than the returned value.

Returns
Maximum length in bits.

Reimplemented from PacketItem.

◆ get_packet_type()

() -> str

Gets the packet type.

Returns
The name of the packet type.

◆ get_parameter_list()

(full_name : bool  
mod_only : bool  
) -> list[str]

Returns a list of all parameters within the packet.

Parameters
[in]full_nameTrue, indicates to return parameter fully qualified names.
[in]mod_onlyIndicates if the returned data should be limited to modifiable parameters.
Returns
list[str] containing of all parameters within the packet.

Reimplemented from PacketItem.

◆ get_polynomial_info()

() -> Optional[ChecksumPolynomialInfo]

Gets CRC32 Generic information.

Retrieves the CRC32 configuration if checksum type is PacketChecksumType.CT_GENERIC_CRC32.

Returns
ChecksumPolynomialInfo containing polynomial information for Checksum or None if not PacketChecksumType.CT_GENERIC_CRC32.

◆ get_sequence_flags_parameter()

() -> str

Returns the name of the parameter that is used for the sequence flags of the packet.

A blank name indicates that the sequence flags parameter has not been set. If the returned value is not blank, then the sequence flags attributes associated with the parameter can be retrieved using get_sequence_flag_parameter_info().

Returns
The name of the sequence flags parameter if not in use.

◆ get_sequence_flags_parameter_info()

Gets the sequence flags parameter's attributes.

Retrieves the zone (header, data, trailer) where the sequence flag parameter can be found. Details about the sequence flag parameter can be retrieved with find_parameter().

Returns
Data class containing sequence flag location information.
Exceptions
TrekError15007 - TREK_DATA_DOES_NOT_EXIST

◆ get_sorted_parameter_list()

(full_name : bool  
mod_only : bool  
) -> list[str]

Returns a sorted list of all parameters within a collection by their start location.

Parameters
[in]full_nameTrue, indicates to return parameter fully qualified names.
[in]mod_onlyIndicates if the returned data should be limited to modifiable parameters.
Returns
list[str] containing of all parameters sorted by start location.

Reimplemented from PacketItem.

◆ get_timestamp_parameter()

() -> str

Returns the name of the parameter that is used for the time stamp of the packet.

A blank name indicates that the time stamp parameter has not been set. If the returned value is not blank, then the time stamp attributes associated with the parameter can be retrieved using get_timestamp_parameter_info().

Returns
The name of the time stamp parameter. Blank if not in use.

◆ get_timestamp_parameter_info()

Gets the time stamp parameter's attributes.

Retrieves the zone (header, data, trailer) where the time stamp parameter can be found, the offset applied to the time (build only), and its parent's start bit. Details about the time parameter can be retrieved with find_parameter().

Note
Unlike the other packet attributes, the innermost time stamp is returned as this value is best used to determine the time of the source data.
Returns
Data class containing parameter location information.
Exceptions
TrekError15007 - TREK_DATA_DOES_NOT_EXIST

◆ get_validation_errors()

() -> str

Gets a string of the last validation errors.

Returns
A string containing validation errors.

◆ has_checksum_error()

() -> bool

Determines if the last packet extraction had a checksum error.

Returns
True if length error was detected.

◆ has_data_zone()

() -> bool

Determines if the packet has a data zone.

Returns
True, if a packet data is currently set.

◆ has_header_zone()

() -> bool

Determines if the packet has a header zone.

Returns
True, if packet headers is currently set.

◆ has_length_error()

() -> bool

Determines if the last packet extraction had a length error.

Returns
True if length error was detected.

◆ has_modifiable_data()

(data_zone_only : bool  ) -> bool

Determines if the packet has any modifiable data.

Parameters
[in]data_zone_onlyIf True, limits the search to the data zone.
Returns
False if no parameter is modifiable.

Reimplemented from PacketItem.

◆ has_trailer_zone()

() -> bool

Determines if the packet has a trailer zone.

Returns
True, if packet trailer is currently set.

◆ has_variable_length_data()

() -> bool

Determines if the parameter collection has any variable length data.

Returns
True, if parameter has any variable length data.

Reimplemented from PacketItem.

◆ initialize()

() -> None

Initializes the object.

Clears any set values in the Packet. New instances do not need to be initialized.

Reimplemented from NamedItem.

◆ is_complete()

() -> bool

Determines if the packet definition is considered complete.

Returns
true if all parameters have values.
false If any parameter does not have a value or none of the header, data, or trailer zones are set.

Reimplemented from PacketItem.

◆ is_modifiable()

(top_level : bool  ) -> bool

Determines if any of the data is modifiable.

Packets are considered modifiable if the data zone contains any modifiable data. If the data zone contains nested packets, any parameter in that packet can make the top level packet modifiable.

Parameters
[in]top_levelDesignates this packet as top level. Default is true.
Returns
True, if one or more parameters in the data zone are modifiable.

Reimplemented from PacketItem.

◆ load_file()

(filename : str ) -> None

Loads the Packet definition from the specified file.

Reads an XML format for the Packet. It can be written in with save_file().

Parameters
[in]filenameThe file from which to load the parameter object.

◆ print_definition()

(include_value : bool  ) -> str

Returns a string with basic information about all parameters in the packet.

The returned string contains the short name, fully qualified name, start bit, data type, length, and (optionally) value for each parameter in the packet. The parameters are returned based on the order of the start bit. Only the first sample of a parameter's value is shown.

Parameters
[in]include_valueIf value should be included.
Returns
The definition as a string.

◆ print_packet()

(buffer : bytearray ) -> str

This method is used to print all of the headers in the packet and a hexidecimal representation of the packet contents.

This is the method used by the Data GUI to view packets.

Parameters
[in]bufferThe packet to print.
Returns
The packet as string.

◆ remove_all_identifiers()

() -> None

Removes all identifiers from the packet.

The parameters corresponding to the identifiers are not removed.

◆ remove_data()

() -> None

Removes the data zone from the packet.

Deletes the current data, if any, from the packet. add_data() can be used to add a new data. The global packet map is cleared as part of this method.

◆ remove_header()

() -> None

Removes the header zone from the packet.

Deletes the current header, if any, from the packet. add_header() can be used to add a new header. The global packet map is cleared as part of this method.

◆ remove_identifier()

(name : str ) -> None

Removes the specified parameter as an identifier.

The specified parameter is removed as an identifier for this packet. The parameter corresponding to the name is not removed.

Parameters
[in]nameThe name of the parameter to be removed as an identifier.
Exceptions
TrekError15007 - TREK_DATA_DOES_NOT_EXIST

◆ remove_trailer()

() -> None

Removes the trailer zone from the packet.

Deletes the current trailer, if any, from the packet. add_trailer() can be used to add a new trailer. The global packet map is cleared as part of this method.

◆ save_file()

(filename : str ) -> None

Saves the Packet definition to the specified file.

Writes an XML format for the Packet. It can be read in with load_file().

Parameters
[in]filenameThe file to save the packet object.

◆ set_checksum_parameter()

(param_name : str 
param_info : ChecksumParameterInfo 
poly_info : Optional[ChecksumPolynomialInfo]  
) -> None

Sets the checksum parameter for the packet.

The checksum parameter is used when calling Build to calculate a checksum for the packet as it is built. If the checksum parameter is no longer needed call the clear_checksum_parameter() method. The table below shows the data type that is required for each checksum type.

Parameters
[in]param_nameThe name of the parameter used for checksum.
[in]param_infoChecksum parameter attributes.
[in]poly_infoThe Polynomial CRC32 information for type PacketChecksumType.CT_GENERIC_CRC32 (optional).
Exceptions
TrekError15007 - TREK_DATA_DOES_NOT_EXIST,

15008 - TREK_DATA_INVALID_DATA_TYPE,

15101 - TREK_DATA_NOT_IN_ZONE

◆ set_counter_parameter()

(param_name : str 
param_info : CounterParameterInfo 
) -> def

Sets the counter parameter for the packet.

The counter parameter is used when calling build() to set a counter for the packet as it is built. If the counter parameter is no longer needed call the clear_counter_parameter() method. If min_count and max_count are both set to 0 (default), the counter will use the full size of the counter based on its length.

Parameters
[in]param_nameThe name of the parameter used for the counter.
[in]param_infoCounter parameter attributes.
Exceptions
TrekError15007 - TREK_DATA_DOES_NOT_EXIST,

15065 - TREK_DATA_INVALID_LENGTH

◆ set_length_parameter()

(param_name : str 
param_info : LengthParameterInfo 
) -> None

Sets the length parameter for the packet.

The length parameter is used when calling build() to calculate the length of the packet as it is built. This is necessary for variable length packets, but can be omitted for fixed length packets if desired. If the length parameter is no longer needed call the clear_length_parameter() method.

Parameters
[in]param_nameThe name of the parameter used for length.
[in]param_infoLength parameter attributes.
Exceptions
TrekError15007 - TREK_DATA_DOES_NOT_EXIST

◆ set_modifiable_flag_for_all_parameters()

(new_value : bool ) -> None

Sets the modifiable flag for all parameters currently in the packet.

Parameters
[in]new_valueThe new flag.

◆ set_packet_type()

(new_type : str ) -> None

Sets the packet type.

Only used in creating new templates.

Parameters
[in]new_typeThe new type name.

◆ set_sequence_flags_parameter()

(param_name : str 
param_info : SequenceFlagParameterInfo  
) -> None

Sets the sequence flags parameter for the packet.

The sequence flags parameter is only used to specify if CCSDS packet segmentation is supported for the packet. If the sequence flag parameter is no longer needed call the clear_sequence_flag_parameter() method.

Parameters
[in]param_nameThe name of the parameter used for sequence flag.
[in]param_infoSequence flag parameter attributes.
Exceptions
TrekError15007 - TREK_DATA_DOES_NOT_EXIST

◆ set_timestamp_offset()

(offset : float ) -> None

Sets an offset for the current system time to use when building packets.

The offset can be used to simulate time for periods other than the current time. This value is only used for build(). The offset is not applied when extracting the data.

Parameters
[in]offsetThe offset in seconds.

◆ set_timestamp_parameter()

(param_name : str 
param_info : TimeStampParameterInfo 
) -> None

Sets the time stamp parameter for the packet.

The time stamp parameter is used when calling Build to set the current time for the packet as it is built. If the time stamp parameter is no longer needed call the clear_timestamp_parameter() method.

Note
The time stamp parameter specified cannot be in a nested packet.
Parameters
[in]param_nameThe name of the parameter to be used for time stamp.
[in]param_infoThe timestamp parameter configuration info.
Exceptions
TrekError15007 - TREK_DATA_DOES_NOT_EXIST

◆ update_expected_value()

(name : str 
new_value : int 
) -> None

Updates the expected value for an identifier.

Parameters
[in]nameThe name of the identifier.
[in]new_valueThe value for the identifier.
Exceptions
TrekError15007 - TREK_DATA_DOES_NOT_EXIST

◆ validate()

() -> int

Validates that the data contained in the packet is logically correct.

Checks the data within the packet for errors that could cause the code to crash. Validation is performed as data is populated with information, but it is possbile to bypass some of these checks if the data is read in from a file (load_file()) or data is deleted.

Returns
The number of validation errors found.