-
Notifications
You must be signed in to change notification settings - Fork 0
fix: add LAN disable and SD stream interface setup to StartSdCardLoggingAsync #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -381,6 +381,13 @@ public async Task StartSdCardLoggingAsync(string? fileName = null, string? chann | |
| throw new InvalidOperationException("Device is not connected."); | ||
| } | ||
|
|
||
| if (!IsUsbConnection) | ||
| { | ||
| throw new InvalidOperationException( | ||
| "SD card logging requires a USB/serial connection. " + | ||
| "The SD card and WiFi/LAN share the SPI bus, so SD operations cannot be performed over a network connection."); | ||
| } | ||
|
|
||
| cancellationToken.ThrowIfCancellationRequested(); | ||
|
|
||
| var extension = format switch | ||
|
|
@@ -399,9 +406,18 @@ public async Task StartSdCardLoggingAsync(string? fileName = null, string? chann | |
| // SdCardLogFormat integer values map 1:1 to SYSTem:STReam:FORmat SCPI arguments | ||
| var formatCommand = new ScpiMessage($"SYSTem:STReam:FORmat {(int)format}"); | ||
|
|
||
| // SD card and LAN share the SPI bus on the hardware, so LAN must be | ||
| // disabled before the SD card can be used. | ||
| Send(ScpiMessageProducer.DisableNetworkLan); | ||
| await Task.Delay(100, cancellationToken); | ||
|
|
||
| Send(ScpiMessageProducer.EnableStorageSd); | ||
| await Task.Delay(100, cancellationToken); | ||
|
|
||
| // Route the data stream to the SD card interface. | ||
| Send(ScpiMessageProducer.SetStreamInterface(StreamInterface.SdCard)); | ||
| await Task.Delay(100, cancellationToken); | ||
|
|
||
| Send(ScpiMessageProducer.SetSdLoggingFileName(logFileName)); | ||
| await Task.Delay(100, cancellationToken); | ||
|
|
||
|
|
@@ -439,6 +455,12 @@ public Task StopSdCardLoggingAsync(CancellationToken cancellationToken = default | |
| StopStreaming(); | ||
| Send(ScpiMessageProducer.DisableStorageSd); | ||
|
|
||
| // Restore stream interface to USB so subsequent non-SD operations work. | ||
| if (IsUsbConnection) | ||
| { | ||
| Send(ScpiMessageProducer.SetStreamInterface(StreamInterface.Usb)); | ||
| } | ||
|
|
||
|
Comment on lines
455
to
+463
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2. Lan not restored on stop StopSdCardLoggingAsync disables SD storage but never re-enables LAN after StartSdCardLoggingAsync disabled it, leaving the device in a LAN-disabled state after logging. This can break later network operations unless callers know to manually call PrepareLanInterface. Agent Prompt
|
||
| _isLoggingToSdCard = false; | ||
|
|
||
| return Task.CompletedTask; | ||
|
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.