fix: batch of small bug fixes and test coverage (#204, #311, #282, #264) - #325
Conversation
…#204) Ports the wire-format regression test from daqifi-desktop, which is removing its direct Google.Protobuf reference now that Core owns the protocol layer. Guards against protobuf schema drift silently breaking real-device discovery responses.
…ing (closes #311) PopulateAnalogChannels previously substituted 65535 for a missing analog_in_res with no warning anywhere, which silently scaled every sample wrong on devices (e.g. NQ3) that never report resolution. Now a missing resolution logs a Trace warning naming the device, and IAnalogChannel/AnalogChannel expose ResolutionIsAssumed so consumers can distinguish a device-reported resolution from a guessed one and warn rather than plot 4x-wrong data as real. Also documents the Resolution convention (max raw count, i.e. 2^bits - 1) and adds AnalogChannel coverage for 12/18/24-bit resolutions.
…ess error (closes #282) Send<T> only ever worked for string payloads; any other IOutboundMessage<T> threw NotImplementedException with a stale "later steps" comment even though the transport abstraction it was waiting on already landed. Non-string payloads (or a string payload with no producer) now write directly to the underlying stream via IOutboundMessage<T>.GetBytes(), which already knows how to serialize itself regardless of T. The producer-less (name, ipAddress) constructor still reports Connected (kept for compatibility with existing lifecycle tests), but Send now throws a clear InvalidOperationException naming the missing transport instead of the misleading NotImplementedException. Also scrubs a stray "// test change" comment left on IDevice.cs.
…loses #264) SdCardFileReceiver.ReceiveAsync returned a successful 0-byte result when the device served an empty, marker-only transfer (__END_OF_FILE__ with no preceding file bytes), which DownloadSdCardFileAsync then reported as a clean FileSize=0 "success." A device whose SD subsystem is wedged or not yet ready produces exactly this shape, so the silent success made a transient device-readiness problem look like a data or import bug downstream. ReceiveAsync now throws SdCardEmptyTransferException when the EOF marker arrives with zero preceding bytes. DownloadSdCardFileAsync retries the GET once on this exception, mirroring the bounded retry GetSdCardFilesAsync's LIST path already uses for the same class of transient SD-subsystem hiccup, before letting the exception surface. Bench-verified on a real Nyquist 1 device: a healthy download (20,118 bytes) completes normally with no retry triggered and no behavior change on the non-empty path.
PR Summary by QodoFix device send/SD download edge cases; surface assumed ADC resolution; add protocol tests
AI Description
Diagram
High-Level Assessment
Files changed (13)
|
|
Thanks for the review, @qodo-code-review[bot]. Addressing the High-Level Assessment points:
No inline code-level findings were posted on this PR (0 review comments, 0 formal reviews) — only the summary/assessment above, which is what this reply addresses. Build is green. |
Thanks for the detailed rationale. The decisions are clear and consistent with the current codebase and compatibility goals—especially retaining |
Code Review by Qodo
Context used 1. Concurrent stream writes
|
|
Thanks for the detailed findings, @qodo-code-review[bot]. Triage: 1. Concurrent stream writes (Send) — Valid theoretical race: the new direct-write path for non-string payloads and 2. Empty SD file blocked — This is the most substantive one and you're right that it's architecturally real: 3. Trace warning can spam — Agreed, fixed in bce6cce: the warning now logs once per device instance and re-arms only if the device later reports a real resolution and then regresses back to omitting it. Added test coverage for both the throttling and the re-arm behavior. All existing tests + new coverage pass (1515 tests, 0 failures). |
Thanks for the thorough triage. The dispositions are clear:
The reported test result—1,515 tests passing with zero failures—provides good coverage for the merged changes. |
Summary
Four small, independent fixes/test additions batched into one PR:
DaqifiOutMessageparser test from daqifi-desktop (which is removing its directGoogle.Protobufreference now that Core owns the protocol layer). Guards against protobuf schema drift silently breaking real-device discovery responses.PopulateAnalogChannelssilently substituted65535for a missinganalog_in_reswith no warning anywhere, silently scaling every sample wrong on devices (e.g. NQ3) that never report resolution. Now logs aTracewarning naming the device, andIAnalogChannel/AnalogChannelexposeResolutionIsAssumedso consumers can distinguish a device-reported resolution from a guessed one. Also documents theResolutionconvention (max raw count, i.e.2^bits - 1) and adds coverage for 12/18/24-bit resolutions.Send<T>only ever worked for string payloads; any otherIOutboundMessage<T>threwNotImplementedExceptionwith a stale "later steps" comment even though the transport abstraction it was waiting on already landed. Non-string payloads now write directly to the underlying stream viaIOutboundMessage<T>.GetBytes(). The producer-less(name, ipAddress)constructor still reportsConnected(kept for compatibility with existing lifecycle tests), butSendnow throws a clearInvalidOperationExceptionnaming the missing transport instead of the misleadingNotImplementedException. Also scrubs a stray// test changecomment onIDevice.cs.SdCardFileReceiver.ReceiveAsyncreturned a successful 0-byte result when the device served an empty, marker-only transfer, whichDownloadSdCardFileAsyncreported as a cleanFileSize=0"success" — making a wedged/not-ready SD subsystem look like a data or import bug downstream. Now throwsSdCardEmptyTransferExceptionon a marker-only transfer, andDownloadSdCardFileAsyncretries the GET once, mirroringGetSdCardFilesAsync's existing LIST retry for the same class of transient hiccup.Test plan
dotnet build— clean, 0 warnings/errorsdotnet test src/Daqifi.Core.Tests— 1513 passed, 2 skipped (pre-existing), 0 failed, both net9.0/net10.0--sd-listand--sd-downloadof an existing 20,118-byte log file both complete normally with no retry triggered and noSdCardEmptyTransferException— confirms the healthy download path is unaffected