-
Notifications
You must be signed in to change notification settings - Fork 32
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
[feature] Bitfield record class #59
Open
ngjunsiang
wants to merge
13
commits into
open-dis:master
Choose a base branch
from
ngjunsiang:feat-bitfield
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is required for bitfields to be able to read or write an arbitrary number of bytes from/to the stream.
This might change in future
…sses These two classes require the use of bitfields, which until now has not been implemented. The interface and design of these two classes is not yet final. Discussion and testing of this interface is recommended before finalization and further work on other bitfield records.
This follows the pattern established by the classes in dis7.py
Initial test for bitfield class
The fields fall back on default size for c_uint if not specified, resulting in the bitfield packing a 16-bit bitfield into 4 bytes instead of 2. This fix induces the correct packing behaviour.
This was missed in an earlier refactor that converted length/count attributes into properties.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduction
The PDUs in IEEE1278.1-2012 contain structured, hierarchical records, of which three kinds can be identified:
A. fixed-size records, with a fixed marshalled size that is known upfront, and record fields have octet-multiple sizes
B. variable-size records, with a variable marshalled size that is not known upfront, and is typically included in one of the record fields as a length or count.
C. fixed-size bitfield enums/records, with fields that are non-octet-multiple sizes
This is a first attempt at implementing the last category (C), involving record fields with non-octet-multiple sizes.
All tests pass so far.
Changes
New method for reading bytes from stream
DataInputStream
andDataOutputStream
getread_bytes()
andwrite_byte()
methods respectively that allow reading an arbitrary number of raw bytes from the stream , and writing a byte sequence of arbitrary size to the stream.New namespace,
record
The new classes are in a separate file, record.py, to avoid dumping its required imports into dis7.
If this namespacing arrangement is preferable I will gradually migrate other records over to this module as I work on them as well. This will leave dis7.py primarily for PDU classes.
Sample bitfield class definitions
In record.py are a bitfield class factory function,
bitfield()
, and two sample classes,SpreadSpectrum
andNetId
. I have also pushed a small change to dis7.py, which affectsModulationType
(which usesSpreadSpectrum
) and thus theTransmitterPdu
class as well.Minor bugfix
Also included is a small fix to SignalPdu, left over from #56.
Requests
Since this PR proposes an interface for bitfields, I would prefer to merge it into a
testing
branch first and keep it apart frommaster
until sufficient time has passed for users and contributors to give it a run.If this is okay, please reject this PR and I will make another one for
testing
branch after it is created.Related/affected issues/PRs
marshalledSize()
method that returns the bytesize of the complete record. Consider this an experiment for that proposal as well.marshalledSize()
method, will make Boundary padding for records and PDUs #53 easier as it provides an easy way to obtain the length of records.SpreadSpectrum
completes the implementation ofModulationType
, which means thattestTransmitterPdu.py
can now incorporate themodulationType
attribute into its testing as well (it currently stops atpower
)