Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add directive code byte to data length #6

Merged
merged 9 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions microservices/CFDP/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ source ENV['RUBYGEMS_URL'] || "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '>= 7.0.0'
gem 'rails', '~> 7.1.0'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.9.3', require: false

# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
gem 'rack-cors', '>= 1.1'
gem 'rack-cors', '~> 2.0'

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data'
Expand All @@ -21,7 +21,7 @@ group :development, :test do
end

group :test do
gem 'mock_redis'
gem 'mock_redis', '0.39'
end

if ENV['OPENC3_DEVEL']
Expand Down
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
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
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
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
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
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
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
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
2 changes: 1 addition & 1 deletion playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"main": "index.js",
"license": "MIT",
"devDependencies": {
"@playwright/test": "^1.33.0"
"@playwright/test": "^1.39.0"
},
"scripts": {}
}
Loading