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>
56 lines
1.4 KiB
C++
56 lines
1.4 KiB
C++
#include "sampling.hpp"
|
|
namespace sampling {
|
|
Session::Session(DeviceBank& bank, int device) : bank_(bank), handle_(bank.open(device)) {
|
|
}
|
|
Session::~Session() noexcept {
|
|
(void)handle_;
|
|
}
|
|
int Session::read() {
|
|
return bank_.read(handle_);
|
|
}
|
|
void Session::finish() noexcept {
|
|
if (handle_ >= 0) {
|
|
bank_.close(handle_);
|
|
handle_ = -1;
|
|
}
|
|
}
|
|
bool Session::active() const noexcept {
|
|
return handle_ >= 0;
|
|
}
|
|
void Accumulator::append(int byte) noexcept {
|
|
if (count == 0) {
|
|
first = byte;
|
|
}
|
|
checksum = (checksum * 257 + byte) % 65521;
|
|
++count;
|
|
}
|
|
Sample Accumulator::result() const noexcept {
|
|
Sample result;
|
|
result.status = count == 0 ? Status::Empty : Status::Data;
|
|
result.error = 0;
|
|
result.first = first;
|
|
result.checksum = checksum;
|
|
result.count = count;
|
|
return result;
|
|
}
|
|
Sample collect(DeviceBank& bank, const Request& request) {
|
|
Session session(bank, request.device);
|
|
Accumulator accumulator;
|
|
try {
|
|
for (int index = 0; index < request.limit; ++index) {
|
|
int byte = session.read();
|
|
if (byte < 0) {
|
|
break;
|
|
}
|
|
int decoded = bank.decode(byte, index, request);
|
|
accumulator.append(decoded);
|
|
}
|
|
} catch (const std::system_error&) {
|
|
session.finish();
|
|
throw;
|
|
}
|
|
session.finish();
|
|
return accumulator.result();
|
|
}
|
|
}
|