Skip to content

Commit a85c96d

Browse files
committed
Include CRC is PDU_DATA_LENGTH
1 parent a9db04c commit a85c96d

9 files changed

+18
-7
lines changed

microservices/CFDP/app/models/cfdp_pdu.rb

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
require 'cfdp_pdu/cfdp_pdu_user_ops'
3131

3232
class CfdpPdu < OpenC3::Packet
33+
DIRECTIVE_CODE_BYTE_SIZE = 1
34+
CRC_BYTE_SIZE = 2
35+
3336
def initialize(crcs_required:)
3437
super()
3538
append_item("VERSION", 3, :UINT)

microservices/CFDP/lib/cfdp_pdu/cfdp_pdu_ack.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ def self.build_ack_pdu(
3636

3737
pdu = build_initial_pdu(type: "FILE_DIRECTIVE", destination_entity: destination_entity, transmission_mode: transmission_mode, file_size: 0, segmentation_control: segmentation_control)
3838
pdu_header_part_1_length = pdu.length # Measured here before writing variable data
39+
pdu_header_part_1_length -= CRC_BYTE_SIZE if destination_entity['crcs_required']
3940
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")
40-
pdu_header_part_2_length = pdu_header.length - 1 # Minus 1 = Directive code is part of data per 5.2.1.1
41+
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
4142
if ack_directive_code == "FINISHED" or ack_directive_code == 5
4243
pdu.write("DIRECTION", "TOWARD_FILE_RECEIVER")
4344
else

microservices/CFDP/lib/cfdp_pdu/cfdp_pdu_eof.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ def self.build_eof_pdu(
4040

4141
pdu = build_initial_pdu(type: "FILE_DIRECTIVE", destination_entity: destination_entity, transmission_mode: transmission_mode, file_size: file_size, segmentation_control: segmentation_control)
4242
pdu_header_part_1_length = pdu.length # Measured here before writing variable data
43+
pdu_header_part_1_length -= CRC_BYTE_SIZE if destination_entity['crcs_required']
4344
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")
44-
pdu_header_part_2_length = pdu_header.length - 1 # Minus 1 = Directive code is part of data per 5.2.1.1
45+
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
4546
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)
4647
pdu.write("VARIABLE_DATA", pdu_header + pdu_contents)
4748
pdu.write("PDU_DATA_LENGTH", pdu.length - pdu_header_part_1_length - pdu_header_part_2_length)

microservices/CFDP/lib/cfdp_pdu/cfdp_pdu_file_data.rb

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def self.build_file_data_pdu(
4444

4545
pdu = build_initial_pdu(type: "FILE_DATA", destination_entity: destination_entity, file_size: file_size, segmentation_control: segmentation_control, transmission_mode: transmission_mode)
4646
pdu_header_part_1_length = pdu.length # Measured here before writing variable data
47+
pdu_header_part_1_length -= CRC_BYTE_SIZE if destination_entity['crcs_required']
4748
pdu_header = pdu.build_variable_header(source_entity_id: source_entity['id'], transaction_seq_num: transaction_seq_num, destination_entity_id: destination_entity['id'])
4849
pdu_header_part_2_length = pdu_header.length
4950
pdu_contents = pdu.build_file_data_pdu_contents(offset: offset, file_data: file_data, record_continuation_state: record_continuation_state, segment_metadata: segment_metadata)

microservices/CFDP/lib/cfdp_pdu/cfdp_pdu_finished.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ def self.build_finished_pdu(
4242
pdu = build_initial_pdu(type: "FILE_DIRECTIVE", destination_entity: destination_entity, transmission_mode: transmission_mode, file_size: 0, segmentation_control: segmentation_control)
4343
pdu.write("DIRECTION", "TOWARD_FILE_SENDER")
4444
pdu_header_part_1_length = pdu.length # Measured here before writing variable data
45+
pdu_header_part_1_length -= CRC_BYTE_SIZE if destination_entity['crcs_required']
4546
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")
46-
pdu_header_part_2_length = pdu_header.length - 1 # Minus 1 = Directive code is part of data per 5.2.1.1
47+
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
4748
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)
4849
pdu.write("VARIABLE_DATA", pdu_header + pdu_contents)
4950
pdu.write("PDU_DATA_LENGTH", pdu.length - pdu_header_part_1_length - pdu_header_part_2_length)

microservices/CFDP/lib/cfdp_pdu/cfdp_pdu_keep_alive.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ def self.build_keep_alive_pdu(
3333
pdu = build_initial_pdu(type: "FILE_DIRECTIVE", destination_entity: destination_entity, transmission_mode: transmission_mode, file_size: file_size, segmentation_control: segmentation_control)
3434
pdu.write("DIRECTION", "TOWARD_FILE_SENDER")
3535
pdu_header_part_1_length = pdu.length # Measured here before writing variable data
36+
pdu_header_part_1_length -= CRC_BYTE_SIZE if destination_entity['crcs_required']
3637
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")
37-
pdu_header_part_2_length = pdu_header.length - 1 # Minus 1 = Directive code is part of data per 5.2.1.1
38+
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
3839
pdu_contents = pdu.build_keep_alive_pdu_contents(progress: progress)
3940
pdu.write("VARIABLE_DATA", pdu_header + pdu_contents)
4041
pdu.write("PDU_DATA_LENGTH", pdu.length - pdu_header_part_1_length - pdu_header_part_2_length)

microservices/CFDP/lib/cfdp_pdu/cfdp_pdu_metadata.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ def self.build_metadata_pdu(
5151

5252
pdu = build_initial_pdu(type: "FILE_DIRECTIVE", destination_entity: destination_entity, transmission_mode: transmission_mode, file_size: file_size, segmentation_control: segmentation_control)
5353
pdu_header_part_1_length = pdu.length # Measured here before writing variable data
54+
pdu_header_part_1_length -= CRC_BYTE_SIZE if destination_entity['crcs_required']
5455
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")
55-
pdu_header_part_2_length = pdu_header.length - 1 # Minus 1 = Directive code is part of data per 5.2.1.1
56+
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
5657
if checksum_type_implemented(destination_entity['default_checksum_type'])
5758
checksum_type = destination_entity['default_checksum_type']
5859
else

microservices/CFDP/lib/cfdp_pdu/cfdp_pdu_nak.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ def self.build_nak_pdu(
4545
pdu = build_initial_pdu(type: "FILE_DIRECTIVE", destination_entity: destination_entity, transmission_mode: transmission_mode, file_size: file_size, segmentation_control: segmentation_control)
4646
pdu.write("DIRECTION", "TOWARD_FILE_SENDER")
4747
pdu_header_part_1_length = pdu.length # Measured here before writing variable data
48+
pdu_header_part_1_length -= CRC_BYTE_SIZE if destination_entity['crcs_required']
4849
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")
49-
pdu_header_part_2_length = pdu_header.length - 1 # Minus 1 = Directive code is part of data per 5.2.1.1
50+
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
5051
pdu_contents = pdu.build_nak_pdu_contents(start_of_scope: start_of_scope, end_of_scope: end_of_scope, segment_requests: segment_requests)
5152
pdu.write("VARIABLE_DATA", pdu_header + pdu_contents)
5253
pdu.write("PDU_DATA_LENGTH", pdu.length - pdu_header_part_1_length - pdu_header_part_2_length)

microservices/CFDP/lib/cfdp_pdu/cfdp_pdu_prompt.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ def self.build_prompt_pdu(
3131

3232
pdu = build_initial_pdu(type: "FILE_DIRECTIVE", destination_entity: destination_entity, transmission_mode: transmission_mode, file_size: 0, segmentation_control: segmentation_control)
3333
pdu_header_part_1_length = pdu.length # Measured here before writing variable data
34+
pdu_header_part_1_length -= CRC_BYTE_SIZE if destination_entity['crcs_required']
3435
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")
35-
pdu_header_part_2_length = pdu_header.length - 1 # Minus 1 = Directive code is part of data per 5.2.1.1
36+
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
3637
pdu_contents = pdu.build_prompt_pdu_contents(response_required: response_required)
3738
pdu.write("VARIABLE_DATA", pdu_header + pdu_contents)
3839
pdu.write("PDU_DATA_LENGTH", pdu.length - pdu_header_part_1_length - pdu_header_part_2_length)

0 commit comments

Comments
 (0)