Skip to content

Commit

Permalink
Merge branch 'directive_code_part_of_data_length' of https://github.c…
Browse files Browse the repository at this point in the history
…om/OpenC3/openc3-cosmos-cfdp into directive_code_part_of_data_length
  • Loading branch information
jmthomas committed Nov 14, 2023
2 parents b846c47 + a85c96d commit f2b2465
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 7 deletions.
3 changes: 3 additions & 0 deletions microservices/CFDP/app/models/cfdp_pdu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
require 'cfdp_pdu/cfdp_pdu_user_ops'

class CfdpPdu < OpenC3::Packet
DIRECTIVE_CODE_BYTE_SIZE = 1
CRC_BYTE_SIZE = 2

def initialize(crcs_required:)
super()
append_item("VERSION", 3, :UINT)
Expand Down
3 changes: 2 additions & 1 deletion microservices/CFDP/lib/cfdp_pdu/cfdp_pdu_ack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ def self.build_ack_pdu(

pdu = build_initial_pdu(type: "FILE_DIRECTIVE", destination_entity: destination_entity, transmission_mode: transmission_mode, file_size: 0, segmentation_control: segmentation_control)
pdu_header_part_1_length = pdu.length # Measured here before writing variable data
pdu_header_part_1_length -= CRC_BYTE_SIZE if destination_entity['crcs_required']
pdu_header = pdu.build_variable_header(source_entity_id: source_entity['id'], transaction_seq_num: transaction_seq_num, destination_entity_id: destination_entity['id'], directive_code: "ACK")
pdu_header_part_2_length = pdu_header.length - 1 # Minus 1 = Directive code is part of data per 5.2.1.1
pdu_header_part_2_length = pdu_header.length - DIRECTIVE_CODE_BYTE_SIZE # Minus 1 = Directive code is part of data per 5.2.1.1
if ack_directive_code == "FINISHED" or ack_directive_code == 5
pdu.write("DIRECTION", "TOWARD_FILE_RECEIVER")
else
Expand Down
3 changes: 2 additions & 1 deletion microservices/CFDP/lib/cfdp_pdu/cfdp_pdu_eof.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ def self.build_eof_pdu(

pdu = build_initial_pdu(type: "FILE_DIRECTIVE", destination_entity: destination_entity, transmission_mode: transmission_mode, file_size: file_size, segmentation_control: segmentation_control)
pdu_header_part_1_length = pdu.length # Measured here before writing variable data
pdu_header_part_1_length -= CRC_BYTE_SIZE if destination_entity['crcs_required']
pdu_header = pdu.build_variable_header(source_entity_id: source_entity['id'], transaction_seq_num: transaction_seq_num, destination_entity_id: destination_entity['id'], directive_code: "EOF")
pdu_header_part_2_length = pdu_header.length - 1 # Minus 1 = Directive code is part of data per 5.2.1.1
pdu_header_part_2_length = pdu_header.length - DIRECTIVE_CODE_BYTE_SIZE # Minus 1 = Directive code is part of data per 5.2.1.1
pdu_contents = pdu.build_eof_pdu_contents(condition_code: condition_code, file_checksum: file_checksum, file_size: file_size, canceling_entity_id: canceling_entity_id)
pdu.write("VARIABLE_DATA", pdu_header + pdu_contents)
pdu.write("PDU_DATA_LENGTH", pdu.length - pdu_header_part_1_length - pdu_header_part_2_length)
Expand Down
1 change: 1 addition & 0 deletions microservices/CFDP/lib/cfdp_pdu/cfdp_pdu_file_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def self.build_file_data_pdu(

pdu = build_initial_pdu(type: "FILE_DATA", destination_entity: destination_entity, file_size: file_size, segmentation_control: segmentation_control, transmission_mode: transmission_mode)
pdu_header_part_1_length = pdu.length # Measured here before writing variable data
pdu_header_part_1_length -= CRC_BYTE_SIZE if destination_entity['crcs_required']
pdu_header = pdu.build_variable_header(source_entity_id: source_entity['id'], transaction_seq_num: transaction_seq_num, destination_entity_id: destination_entity['id'])
pdu_header_part_2_length = pdu_header.length
pdu_contents = pdu.build_file_data_pdu_contents(offset: offset, file_data: file_data, record_continuation_state: record_continuation_state, segment_metadata: segment_metadata)
Expand Down
3 changes: 2 additions & 1 deletion microservices/CFDP/lib/cfdp_pdu/cfdp_pdu_finished.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ def self.build_finished_pdu(
pdu = build_initial_pdu(type: "FILE_DIRECTIVE", destination_entity: destination_entity, transmission_mode: transmission_mode, file_size: 0, segmentation_control: segmentation_control)
pdu.write("DIRECTION", "TOWARD_FILE_SENDER")
pdu_header_part_1_length = pdu.length # Measured here before writing variable data
pdu_header_part_1_length -= CRC_BYTE_SIZE if destination_entity['crcs_required']
pdu_header = pdu.build_variable_header(source_entity_id: source_entity['id'], transaction_seq_num: transaction_seq_num, destination_entity_id: destination_entity['id'], directive_code: "FINISHED")
pdu_header_part_2_length = pdu_header.length - 1 # Minus 1 = Directive code is part of data per 5.2.1.1
pdu_header_part_2_length = pdu_header.length - DIRECTIVE_CODE_BYTE_SIZE # Minus 1 = Directive code is part of data per 5.2.1.1
pdu_contents = pdu.build_finished_pdu_contents(condition_code: condition_code, delivery_code: delivery_code, file_status: file_status, filestore_responses: filestore_responses, fault_location_entity_id: fault_location_entity_id)
pdu.write("VARIABLE_DATA", pdu_header + pdu_contents)
pdu.write("PDU_DATA_LENGTH", pdu.length - pdu_header_part_1_length - pdu_header_part_2_length)
Expand Down
3 changes: 2 additions & 1 deletion microservices/CFDP/lib/cfdp_pdu/cfdp_pdu_keep_alive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ def self.build_keep_alive_pdu(
pdu = build_initial_pdu(type: "FILE_DIRECTIVE", destination_entity: destination_entity, transmission_mode: transmission_mode, file_size: file_size, segmentation_control: segmentation_control)
pdu.write("DIRECTION", "TOWARD_FILE_SENDER")
pdu_header_part_1_length = pdu.length # Measured here before writing variable data
pdu_header_part_1_length -= CRC_BYTE_SIZE if destination_entity['crcs_required']
pdu_header = pdu.build_variable_header(source_entity_id: source_entity['id'], transaction_seq_num: transaction_seq_num, destination_entity_id: destination_entity['id'], directive_code: "KEEP_ALIVE")
pdu_header_part_2_length = pdu_header.length - 1 # Minus 1 = Directive code is part of data per 5.2.1.1
pdu_header_part_2_length = pdu_header.length - DIRECTIVE_CODE_BYTE_SIZE # Minus 1 = Directive code is part of data per 5.2.1.1
pdu_contents = pdu.build_keep_alive_pdu_contents(progress: progress)
pdu.write("VARIABLE_DATA", pdu_header + pdu_contents)
pdu.write("PDU_DATA_LENGTH", pdu.length - pdu_header_part_1_length - pdu_header_part_2_length)
Expand Down
3 changes: 2 additions & 1 deletion microservices/CFDP/lib/cfdp_pdu/cfdp_pdu_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ def self.build_metadata_pdu(

pdu = build_initial_pdu(type: "FILE_DIRECTIVE", destination_entity: destination_entity, transmission_mode: transmission_mode, file_size: file_size, segmentation_control: segmentation_control)
pdu_header_part_1_length = pdu.length # Measured here before writing variable data
pdu_header_part_1_length -= CRC_BYTE_SIZE if destination_entity['crcs_required']
pdu_header = pdu.build_variable_header(source_entity_id: source_entity['id'], transaction_seq_num: transaction_seq_num, destination_entity_id: destination_entity['id'], directive_code: "METADATA")
pdu_header_part_2_length = pdu_header.length - 1 # Minus 1 = Directive code is part of data per 5.2.1.1
pdu_header_part_2_length = pdu_header.length - DIRECTIVE_CODE_BYTE_SIZE # Minus 1 = Directive code is part of data per 5.2.1.1
if checksum_type_implemented(destination_entity['default_checksum_type'])
checksum_type = destination_entity['default_checksum_type']
else
Expand Down
3 changes: 2 additions & 1 deletion microservices/CFDP/lib/cfdp_pdu/cfdp_pdu_nak.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ def self.build_nak_pdu(
pdu = build_initial_pdu(type: "FILE_DIRECTIVE", destination_entity: destination_entity, transmission_mode: transmission_mode, file_size: file_size, segmentation_control: segmentation_control)
pdu.write("DIRECTION", "TOWARD_FILE_SENDER")
pdu_header_part_1_length = pdu.length # Measured here before writing variable data
pdu_header_part_1_length -= CRC_BYTE_SIZE if destination_entity['crcs_required']
pdu_header = pdu.build_variable_header(source_entity_id: source_entity['id'], transaction_seq_num: transaction_seq_num, destination_entity_id: destination_entity['id'], directive_code: "NAK")
pdu_header_part_2_length = pdu_header.length - 1 # Minus 1 = Directive code is part of data per 5.2.1.1
pdu_header_part_2_length = pdu_header.length - DIRECTIVE_CODE_BYTE_SIZE # Minus 1 = Directive code is part of data per 5.2.1.1
pdu_contents = pdu.build_nak_pdu_contents(start_of_scope: start_of_scope, end_of_scope: end_of_scope, segment_requests: segment_requests)
pdu.write("VARIABLE_DATA", pdu_header + pdu_contents)
pdu.write("PDU_DATA_LENGTH", pdu.length - pdu_header_part_1_length - pdu_header_part_2_length)
Expand Down
3 changes: 2 additions & 1 deletion microservices/CFDP/lib/cfdp_pdu/cfdp_pdu_prompt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ def self.build_prompt_pdu(

pdu = build_initial_pdu(type: "FILE_DIRECTIVE", destination_entity: destination_entity, transmission_mode: transmission_mode, file_size: 0, segmentation_control: segmentation_control)
pdu_header_part_1_length = pdu.length # Measured here before writing variable data
pdu_header_part_1_length -= CRC_BYTE_SIZE if destination_entity['crcs_required']
pdu_header = pdu.build_variable_header(source_entity_id: source_entity['id'], transaction_seq_num: transaction_seq_num, destination_entity_id: destination_entity['id'], directive_code: "PROMPT")
pdu_header_part_2_length = pdu_header.length - 1 # Minus 1 = Directive code is part of data per 5.2.1.1
pdu_header_part_2_length = pdu_header.length - DIRECTIVE_CODE_BYTE_SIZE # Minus 1 = Directive code is part of data per 5.2.1.1
pdu_contents = pdu.build_prompt_pdu_contents(response_required: response_required)
pdu.write("VARIABLE_DATA", pdu_header + pdu_contents)
pdu.write("PDU_DATA_LENGTH", pdu.length - pdu_header_part_1_length - pdu_header_part_2_length)
Expand Down

0 comments on commit f2b2465

Please sign in to comment.