Skip to content

Add HIL-TDD guidance documentation for PoKeysHal driver - #137

Merged
zarfld merged 1 commit into
mainfrom
fix/copilot-customization-post-135
Jul 30, 2026
Merged

Add HIL-TDD guidance documentation for PoKeysHal driver#137
zarfld merged 1 commit into
mainfrom
fix/copilot-customization-post-135

Conversation

@zarfld

@zarfld zarfld commented Jul 30, 2026

Copy link
Copy Markdown
Owner
  • Introduced TDD Guidance for PokeysHal1.md and PokeysHal2.md to outline HIL-TDD principles and workflows.
  • Established a clear separation between unit tests and HIL tests, emphasizing the importance of hardware verification.
  • Documented the correct workflow for HIL-assisted Unit TDD, including the use of HIL observations as test oracles.
  • Revised test layering to distinguish between unit tests, HAL integration tests, and HIL acceptance tests.
  • Created a detailed HIL fixture contract and proposed repository structure for HIL tests.
  • Added comprehensive HIL guidance thoughts to ensure clarity on the HIL testing process and its integration with existing workflows.

Description

Brief description of the changes in this PR.

Related Issues

Fixes #
Implements #
Part of #

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Real-time / HAL component change

Traceability

  • Requirements: #
  • Architecture / Design: #
  • Tests: #

Testing

Describe how this was tested:

  • bash test_compile.sh passes
  • make -f Makefile.noqmake builds without errors
  • HAL userspace component loads (halrun / loadusr)
  • HAL RT component loads (halrun / loadrt)
  • No memory allocation in RT paths
  • No blocking calls in RT paths

Real-Time Safety Checklist (if RT code changed)

  • No malloc/free in real-time thread paths
  • No blocking socket operations (all sockets are O_NONBLOCK)
  • RT function completes within timing budget (<50µs for PREEMPT_RT userspace/soft-RT; <5µs for RTAI/hard-RT kernel module)
  • mlockall used where required
  • HAL pin types are correct (hal_s32_t, hal_bit_t, hal_float_t)

Checklist

  • All tests pass
  • Documentation updated alongside code changes
  • No unrelated files changed
  • Traceability links verified (PR links to implementing issue)

- Introduced TDD Guidance for PokeysHal1.md and PokeysHal2.md to outline HIL-TDD principles and workflows.
- Established a clear separation between unit tests and HIL tests, emphasizing the importance of hardware verification.
- Documented the correct workflow for HIL-assisted Unit TDD, including the use of HIL observations as test oracles.
- Revised test layering to distinguish between unit tests, HAL integration tests, and HIL acceptance tests.
- Created a detailed HIL fixture contract and proposed repository structure for HIL tests.
- Added comprehensive HIL guidance thoughts to ensure clarity on the HIL testing process and its integration with existing workflows.
Copilot AI review requested due to automatic review settings July 30, 2026 12:37
@zarfld
zarfld merged commit 032aaba into main Jul 30, 2026
3 checks passed
@zarfld
zarfld deleted the fix/copilot-customization-post-135 branch July 30, 2026 12:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds Hardware-in-the-Loop (HIL) / TDD guidance documentation for the PoKeysHal driver, describing recommended test layering (unit vs HAL smoke vs HIL fixture vs machine integration) and capturing a proposed PoKeys57E loopback fixture contract.

Changes:

  • Added multiple guidance documents describing HIL-assisted unit TDD workflows and test-layer separation.
  • Added PoKeys57E loopback wiring / pin-mode notes intended to support HIL fixture design.
  • Added two “recommendation” documents outlining a proposed repo structure and process for HIL testing artifacts.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
docs/HIL_Setup_4_TDD/TDD_HILguidance_thoughts.md High-level HIL/TDD guidance and proposed instruction/workflow draft.
docs/HIL_Setup_4_TDD/TDD Guidance for PokeysHal1.md HIL-assisted unit TDD workflow and examples of “HIL-derived oracle” unit tests.
docs/HIL_Setup_4_TDD/TDD Guidance for PokeysHal2.md Recommended test layering and proposed split between basic HIL and integration tests.
docs/HIL_Setup_4_TDD/PoKeys57E pin modes.md Fixture wiring/pin-mode capability notes and reuse ideas for PoKeys57E.
docs/HIL_Setup_4_TDD/HIL_TDD_guidance_suggestion1.md Proposed 4-layer artifact structure and workflow recommendations for HIL testing.
docs/HIL_Setup_4_TDD/HIL_moduletests_thoughts.md Second copy of the same recommendation/workflow content (currently duplicated).

@@ -0,0 +1,377 @@
Yes. The existing `Pokeys57E_SimPins.hal` is a good HIL fixture. It already documents the physical loopbacks and uses `wcomp` comparators to turn simulated axis positions into physical PoKeys output pins, which are wired back into PoKeys inputs. That means you can test the full chain:
-> LinuxCNC HAL/motion-facing signal
```

The existing config uses `DEVICE_ID=27295` and `ApplyIniSettings=1`, so the HIL profile should lock to that board unless explicitly overridden. The machine config loads `Pokeys_DM542_XXYZ_mill.hal`, `pokeys_homing.hal`, and then `Pokeys57E_SimPins.hal`, so the current setup already treats the sim pins as part of the HAL stack.
| Machine integration | Full `DM542_XXYZ_mill` config, homing, sim switches, LinuxCNC motion wiring | **Yes** | Yes |
| Full motion validation | Motors/drives/spindle connected | Yes | Yes |

The existing `Pokeys57E_SimPins.hal` is useful evidence of the wiring harness: it documents the loopbacks for digital switch simulation, PWM-to-analog, and pulse-engine-to-encoder paths. But its `wcomp` logic and position-derived simulated switches are already **machine-behavior simulation**, not the minimal primitive HIL test.

Unless the test explicitly belongs to `integration/`.

The full config currently loads `Pokeys_DM542_XXYZ_mill.hal`, `pokeys_homing.hal`, and `Pokeys57E_SimPins.hal`; that makes it a multi-file machine configuration, therefore integration scope.
Physical pin 28 -> pokeys.0.pins.27
```

This is already visible in `Pokeys57E_SimPins.hal`: physical pins 23–26 are driven through `digout.22`–`digout.25`, with `PinFunction 4` selecting digital-output mode.
Comment on lines +1 to +5
# Recommendation

Use **four separate layers**, each with a narrow responsibility:

| Artifact | Purpose | Recommendation |
Comment on lines +425 to +426
[1]: https://docs.github.com/en/copilot/concepts/agents/about-agent-skills?utm_source=chatgpt.com "About agent skills - GitHub Docs"
[2]: https://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-cloud-agent/create-custom-agents?utm_source=chatgpt.com "Creating custom agents for Copilot cloud agent - GitHub Docs"
Comment on lines +425 to +426
[1]: https://docs.github.com/en/copilot/concepts/agents/about-agent-skills?utm_source=chatgpt.com "About agent skills - GitHub Docs"
[2]: https://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-cloud-agent/create-custom-agents?utm_source=chatgpt.com "Creating custom agents for Copilot cloud agent - GitHub Docs"

### 1. Pin-index mapping

The existing HAL file confirms that physical Pin 23 is driven through `pokeys.0.digout.22.out`, physical Pin 24 through `digout.23.out`, and so on. That should become a unit test for the mapping helper, not a scattered assumption.

### 2. PEv2 switch mapping

The INI maps X limit-minus to Pin 28 and X home to Pin 29. Positive limit is disabled. So the unit test should encode exactly that:
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