Skip to content

feat(sd): add progress feedback for SD card format operation #180

@cptkoolbeenz

Description

@cptkoolbeenz

Problem

The SYST:STOR:SD:FORMat command provides no feedback during execution. SD card formatting can take significant time (especially for large cards), leaving users uncertain whether:

  • The operation is still in progress
  • The device has hung
  • The format completed successfully

Proposed Solutions

Option A: Status Query Command (Recommended)

Add SYST:STOR:SD:FORMat? query command that returns format status:

SYST:STOR:SD:FORMat?

Returns:

  • 0 - No format in progress (idle)
  • 1 - Format currently in progress
  • 2 - Format completed successfully (could auto-clear after query)
  • -1 - Format failed (error)

Pros:

  • SCPI-compliant (query form of existing command)
  • Non-blocking - user can poll as frequently as desired
  • Works well with automation/scripting

Option B: Progress Percentage

If the underlying filesystem library provides progress callbacks:

SYST:STOR:SD:FORMat?

Returns: 0-100 representing percentage complete, or -1 for error

Note: May not be feasible depending on SYS_FS_DriveFormat() implementation.

Option C: Periodic Progress Output

Return progress indicators (. or percentage) during format:

SYST:STOR:SD:FORMat
..........  (10%)
..........  (20%)
...
OK

Cons:

  • May interfere with SCPI parsers expecting clean responses
  • Harder to parse programmatically

Implementation Notes

  1. Add state tracking variable for format operation:

    typedef enum {
        SD_FORMAT_IDLE = 0,
        SD_FORMAT_IN_PROGRESS = 1,
        SD_FORMAT_COMPLETE = 2,
        SD_FORMAT_ERROR = -1
    } sd_format_status_t;
  2. The format operation already runs in the SD card task state machine, so adding status tracking should be straightforward.

  3. Consider timeout - if format takes >5 minutes, should it be considered failed?

Acceptance Criteria

  • User can query format status while operation is in progress
  • User can distinguish between "not started", "in progress", and "complete"
  • Errors are reported appropriately
  • Works correctly when queried from USB CDC or WiFi

Related

  • Current format implementation: sd_card_manager.c:SD_CARD_MANAGER_PROCESS_STATE_FORMAT
  • SCPI interface: SCPIStorageSD.c

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions