One user-space repair task per eligible HWE debug-diag / compile-deploy base ID: 320 admitted (C 218, C++ 97, build scripts 5), 1 skipped by the content filter. Each ships a public spec with a check-to-basis table, at least two defects with single-fix fixtures, a symptom-masking fixture and an alternative correct implementation. Claude re-checked all 320: structure, the HWE quality items and trace6 Docker calibration receipts against current digests (320/320 USABLE). Difficulty is unmeasured. Known follow-up: 212 tasks use 120 ad-hoc family names; the next batch maps them to the canonical list. The batch's 1,256-line progress log stays in its factory report and the 36-local branch batch15-hwe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4.0 KiB
4.0 KiB
GPIO session contract
reg_runaccepts the declared C structures in include/registration.h. It returns the same status stored in result.status. A result pointer is required; a null result returns -2. With a result, initialize all defined result fields: consumed/event_count zero, initial_level/final_level -1 until setup succeeds. Unused events are unspecified.- A valid request has pin 0..14, edge RISING(1), FALLING(2), or BOTH(3), count 0..32, stop_after 0..count, and every one of count levels 0 or 1. Null bank/request or any invalid field returns -2 and leaves the bank unchanged. Validate even levels beyond stop_after. Pin 15 belongs to a background service.
- A session acquires export, input direction, selected edge and a watch, in that order. Read its initial physical level after setup. On setup failure return -1, consume no samples, report no events, initial/final -1. Release all resources acquired by this call, including when direction, edge or watch setup fails; do not release a pre-existing owner's resources.
- On successful setup, apply exactly the first stop_after levels to the selected pin in input order. Each drive's tick is tick_base + its zero-based input index using C unsigned arithmetic. consumed is the number applied; final_level is the resulting physical level, or initial_level when stop_after is zero. status is 0 when stop_after equals count, otherwise 1 (controlled cancellation). Both outcomes release the session completely.
- A transition is an event only when the physical level changes and matches the selected edge: rising ends at 1, falling ends at 0, both accepts either. Equal consecutive levels generate no event. Return every matching event in order, serials starting at 1 for each new export, tick and level exactly as supplied. At most 32 transitions are possible; the queue has capacity 32. Event storage beyond event_count has no defined contents.
- Cleanup closes this call's watch, disarms its edge (which discards queued events), then unexports. Cleanup functions are non-injectable. Every session, including cancellation and failed setup, restores export/direction/edge/watch/queue ownership to its entry state. Successful drives leave their physical levels in place after unexport. Never alter another pin's level or resources. In particular the existing background registration on pin 15 must remain active.
- The backend is a stateful software device, not an expected-answer helper. gpio_fault chooses a one-shot failing setup ordinal 1..4 (export/direction/edge/watch); 0 disables injection. A failed operation does not mutate device state. Watch handles bind pin generations, polling removes one queued event, disarm requires no active watch, and unexport requires no edge or watch. Repeated sessions use the same bank and must remain usable.
- The public demo first reads an unsigned initial-level bit mask, creates the background BOTH watch on pin 15, then reads lines: pin edge fault count stop_after tick_base followed by count levels (no levels when count is outside 0..32). It sets gpio_fault before each call. Inputs use fault 0..4. Its stdout is one
Rrow per call: row number, returned status, result status, consumed, initial, final, event_count, then event triples(serial tick level), then|and the snapshot fields declared in the header. This is an observation protocol, not a claim that rows are correct. - Snapshot fields count exported pins, active watches, non-NONE edges and queued events, followed by physical-level, export, input, rising-edge and falling-edge bit masks. Only these defined fields and events[0..event_count) are contractual. No requirement is imposed on unused storage, setup call counts, polling batching or stderr diagnostic bytes.
- Build with the provided Makefile and GCC C11; no hardware, network, external packages, real time or OS GPIO files are involved. Preserve the API and satisfy every clause above. Only src/registration.c is submitted; public backend/header/demo/build files are frozen by the grader and the executable is rebuilt from clean sources.