Repository navigation
Time a binary reply's silence in milliseconds, not whole seconds - #172
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After the first byte, a stall was counted as timeout_ms / 1000 silent 1 s slices, rounded down: timeout_ms = 1500 gave up after one second, and 500 waited a full one. The silence is now counted in the milliseconds asked for, and the last slice is only what's left of the timeout. The first read is unchanged: still one read. Tested on the 54845A: two captures and two visa_query_binary dumps with timeout_ms 1500 and 2500, each about 2 s; a rejected dump in 4.3 s; then *IDN? in 20 ms, headers off and the error queue empty. Found by Copilot in its review of #169. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the millisecond-based binary-reply stall handling update.
No open issues 🎉
What changed in this PR
Updates binary-reply stall handling to count silence in milliseconds rather than whole-second slices, addressing the follow-up deferred from #169. The initial read remains unchanged.
Changes:
- Limits each subsequent read to the remaining silence allowance, preserving whole-second timeout behavior.
- Adds tests for 500, 1500, and 3000 ms silence allowances.
- Bumps the shared version from 1.3.1 to 1.3.2.
| File | Description |
|---|---|
tests/GpibMcp.Tests/InstrumentManagerTests.cs |
Verifies silent-read timeout slices and request counts. |
src/GpibMcp.Core/Instruments/InstrumentManager.cs |
Tracks silence in milliseconds and shortens the final read slice. |
src/Directory.Build.props |
Updates the shared version to 1.3.2. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After a binary reply starts, a stall is now timed in milliseconds rather than in whole 1 s slices. Copilot found this in its review of #169, and it was held back from 1.3.1 until it could be tested on hardware.
The problem
InstrumentManager.QueryBinaryreads in 1 s slices after the first byte, and counted a stall astimeout_ms / 1000silent slices, rounded down (minimum one). Sotimeout_ms = 1500gave up after one silent second, andtimeout_ms = 500waited a full second.The fix
Silence is counted in the milliseconds asked for, and the last slice is only what's left of the timeout: 1500 is a 1000 ms slice then a 500 ms one. A driver may round a short slice up to its next step (300 ms waits about 0.29 s and 500 ms about 1 s over a GPIB-ENET/1000), so the wait can run longer than asked, never shorter. Timeouts in whole seconds, including the 54845A's default, send exactly what they did before.
The first read, which waits for the reply to start, is unchanged and stays one read. Splitting it failed every capture on the 54845A and left the scope unresponsive until it was power-cycled.
Tested
instrument_capture_screencalls at about 2 s each;visa_query_binaryof:DISPlay:DATA? GIF,SCReenwithtimeout_ms1500 and 2500, about 2.1 s each;-108and-420read back;*IDN?in 20 ms, with headers still off and the error queue empty.🤖 Generated with Claude Code