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

Multi variable bit size #1436

Merged
merged 9 commits into from
Jul 29, 2024
Merged

Multi variable bit size #1436

merged 9 commits into from
Jul 29, 2024

Conversation

ryanmelt
Copy link
Member

closes #78

@ryanmelt ryanmelt requested a review from jmthomas July 25, 2024 14:31
Copy link

codecov bot commented Jul 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.77%. Comparing base (6b9608b) to head (3840c30).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1436      +/-   ##
==========================================
+ Coverage   75.65%   75.77%   +0.12%     
==========================================
  Files         603      605       +2     
  Lines       44832    45025     +193     
  Branches      787      787              
==========================================
+ Hits        33918    34119     +201     
+ Misses      10827    10818       -9     
- Partials       87       88       +1     
Flag Coverage Δ
frontend 54.86% <ø> (-0.04%) ⬇️
python 84.00% <ø> (ø)
ruby-api 48.97% <ø> (ø)
ruby-backend 81.07% <ø> (+0.21%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ryanmelt ryanmelt requested a review from JL-Brothers July 25, 2024 14:48
Copy link
Member

@jmthomas jmthomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still need to run locally and see about the coverage and additional testing

required: true
description: The key to access this item
values: .+
example: KEY $.book.title
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this removed? You still have an example in access_tlm.txt of KEY on an ITEM.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was just remove from item_modifiers because it was a dup (I think). It is also in param_item_modifiers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right and that's used by both ... not sure why it didn't get duplicated in the output though

item.bit_size = 30
else
item.bit_size = 62
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are they all 2 bits short?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's above and beyond ... I thought you were just going to do strings, lol

# Skip items before this item and derived items and items with negative bit offsets
next
end
if sitem != item
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The <=> operator in structure_item is based on bit_offset so you might be able to remove this check and just change the above check to sitem.bit_offset <= item.bit_offset

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, but this code appears to work with my current testing.

# Minimum QUIC encoded integer
minimum_data_bits = 6
elsif item.variable_bit_size['length_value_bit_offset'] > 0
minimum_data_bits = item.variable_bit_size['length_value_bit_offset'] * item.variable_bit_size['length_bits_per_count']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is effectively the STRING and BLOCK section?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its STRING, BLOCK, or array

@packet.write("item2_length", 8) # Lengths must be initialized to zero equivalent
item2.variable_bit_size = {'length_item_name' => 'item2_length', 'length_value_bit_offset' => -64, 'length_bits_per_count' => 8}
expect(item2.bit_offset).to eql 48
expect(@packet.buffer).to eql "\x00\x00\x00\x04\x00\x08"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what's going on with this test. How did we get the 4 and 8? Negative offset is a positive value? What happens if you have a value offset of +32?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is handling the case where the value field includes itself in the count (so that has to be subtracted out)
A positive offset would be something like CCSDS where a value of 0 = 1 byte = 8 bits. Don't have a test for that yet.

parser.verify_num_parameters(0, 0, usage)
@current_packet.hidden = true
@current_packet.disabled = true
@current_packet.virtual = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a VIRTUAL packet and how is it going to be used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VIRTUAL packs aren't involved in identification. So it provides a way to declare embedded structures that can be used within packets. Effectively packets in packets.

require 'openc3/conversions/conversion'

module OpenC3
class ObjectReadConversion < Conversion
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used with virtual. This is a new conversion that references a packet structure, and then dumps the BLOCK data into that packet, and returns a hash of key/value pairs generated using the packet structure.

require 'openc3/conversions/object_read_conversion'

module OpenC3
class ObjectWriteConversion < Conversion
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used with virtual, to write a hash of items, into a packet, and then fill in a BLOCK item.

elsif bytes < 0
# Remove extra bytes because we're adjusting smaller
buffer[item_offset + -bytes, -bytes] = ''
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my new buffer adjustment logic

buffer[item_offset, original_length - item_offset]
elsif bytes < 0
# Remove extra bytes because we're adjusting smaller
buffer[item_offset + -bytes, -bytes] = ''
Copy link
Member Author

@ryanmelt ryanmelt Jul 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem right. Let's say we got 7 bytes smaller.
buffer[0 + 7, 7] = "" will destroy a bunch of real data.
Should it always be: buffer[item_offset + 1, -bytes] = '' ?

Copy link
Member Author

@ryanmelt ryanmelt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would like tests for the new conversion classes, and I think packet_config_spec should also include some new tests.

Copy link

@jmthomas
Copy link
Member

Would like tests for the new conversion classes, and I think packet_config_spec should also include some new tests.

Tests added and packet_config.rb is at 96.58%

@ryanmelt
Copy link
Member Author

Looks good!

@jmthomas jmthomas merged commit 632f65c into main Jul 29, 2024
25 checks passed
@jmthomas jmthomas deleted the multi_variable_bit_size branch July 29, 2024 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple variable sized items
2 participants