Skip to content

Conversation

ngjunsiang
Copy link
Contributor

@ngjunsiang ngjunsiang commented Sep 18, 2025

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 and DataOutputStream get read_bytes() and write_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()
  • two sample classes, SpreadSpectrum and NetId.

I have also pushed a small change to dis7.py, which affects ModulationType (which uses SpreadSpectrum) and thus the TransmitterPdu class as well.

Requests

Since this PR proposes an interface for bitfields, I would prefer to merge it into a testing branch first and keep it apart from master 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

  • The Bitfield class incorporates the proposal in Added marshalledSize to all classes #54 to add a marshalledSize() method that returns the bytesize of the complete record. Consider this an experiment for that proposal as well.
  • The addition of bitfield records contributes to progress in null() Function Call? #14, which is held up by the absence of these record classes.
  • bitfield classes, along with the marshalledSize() method, will make Boundary padding for records and PDUs #53 easier as it provides an easy way to obtain the length of records.
  • The namespacing proposal above mirrors Confusing naming for identifiers #52 in its proposal to break up the dis7 module into multiple submodules so that it is easier to differentiate the classes in this package.
  • While not currently open as an issue, the definition of SpreadSpectrum completes the implementation of ModulationType, which means that testTransmitterPdu.py can now incorporate the modulationType attribute into its testing as well (it currently stops at power)
  • TransmitterPDU data appears to be misinterpreted.  #62 requires this PR to be merged, since Modulation Parameter (MP) records include a NetID record which is implemented in this PR.

This is required for bitfields to be able to read or write an arbitrary number of bytes from/to the stream.
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
@ngjunsiang ngjunsiang marked this pull request as ready for review September 18, 2025 14:46
@ngjunsiang
Copy link
Contributor Author

This was previously #59, rebased onto the current master branch.

The tests appear to pass, and only fail at Upload Test Results which doesn't seem to be caused by the codebase itself. I'm marking this PR ready for review.

@leif81
Copy link
Member

leif81 commented Sep 25, 2025

@ngjunsiang thanks for that. It's passing the checks now. Have anything more planned or should I proceed with the merge now?

@ngjunsiang
Copy link
Contributor Author

@leif81 I would suggest to go ahead and merge it first, I'll make a separate PR for further work in this direction.

@leif81 leif81 merged commit 8d1dd7e into open-dis:master Sep 25, 2025
2 checks passed
@ngjunsiang ngjunsiang deleted the feat-bitfield-2025 branch September 25, 2025 11:14
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.

2 participants