Skip to content

fix(plc4j/s7): decode packed BOOL arrays - #2831

Open
kVinsom wants to merge 1 commit into
apache:developfrom
kVinsom:feature/2742-s7-bool-array
Open

kVinsom wants to merge 1 commit into
apache:developfrom
kVinsom:feature/2742-s7-bool-array

Conversation

@kVinsom

@kVinsom kVinsom commented Oct 22, 2026 •

Copy link
Copy Markdown

What does this change, and why?

Reading a BOOL array such as %DB42:214.0[1..8;1]:BOOL returns INTERNAL_ERROR: the optimizer requests packed bytes, but the scalar DataItem parser consumes a full byte per element and eventually produces null values. Decode array elements from the least significant bit of each byte, stopping at the declared element count so padding bits are ignored.

Fixes #2742.

How was it tested?

Added connected-driver regression tests using the existing in-memory S7 transport. They cover the reported address, bit order, byte boundaries, padding bits, scalar BOOL reads, and BYTE/INT array compatibility. Before the fix, all 11 packed-array cases failed while the two scalar cases passed.

On Windows with Temurin Java 21:

./mvnw.cmd -B -ntp -Pwith-java,enable-all-checks -pl plc4j/drivers/s7 -am verify

The S7 module and its reactor dependencies passed verification, including license, dependency, packaging, and coverage checks. S7 results: 329 unit tests and 2 scripted integration tests passed, with no failures or skips. Not tested against a physical PLC.

AI assistance was used to investigate the failure, implement the change, and prepare regression tests.

Checklist

@github-actions

Copy link
Copy Markdown
Contributor

Hi @kVinsom,

Before we review a pull-request from a new contributor, we ask them to introduce themselves on our developer mailing list, dev@plc4x.apache.org. Our contribution guidelines explain why: PLC4X is maintained by a small group of people, and reviewing a change costs us far more time than producing it.

Please post a short introduction covering:

  • who you are and your background, for example the protocols, PLCs or machines you work with
  • what you want to achieve with this pull-request, and the use case behind it
  • whether you plan to keep contributing

To subscribe, send an empty mail to dev-subscribe@plc4x.apache.org (see Getting in contact). Once your introduction is on the list, link the thread from the archive here. A maintainer will then remove the needs-introduction label and continue with the review.

Pull-requests without an introduction may be closed. If such a pull-request contains a valid finding, we may apply the change ourselves.

This comment is posted automatically on pull-requests from first-time contributors.

@github-actions github-actions Bot added the needs-introduction Waiting for the author to introduce themselves on dev@plc4x.apache.org label Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-introduction Waiting for the author to introduce themselves on dev@plc4x.apache.org

Projects

None yet

Development

Successfully merging this pull request may close these issues.

S7: reading a BOOL array fails with NullPointerException in PlcBOOL.of, tag returns INTERNAL_ERROR

1 participant