Skip to content

Add storage management commands for RevisionE panels#16

Open
emaspa wants to merge 1 commit into
usausa:mainfrom
emaspa:add-storage-management
Open

Add storage management commands for RevisionE panels#16
emaspa wants to merge 1 commit into
usausa:mainfrom
emaspa:add-storage-management

Conversation

@emaspa

@emaspa emaspa commented Feb 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #15

Add methods to manage on-device storage for RevisionE serial panels:
- QueryStorageInfo() - returns storage usage in KB
- ListDirectory(path) - lists files in a directory
- DeleteFile(path) - deletes a file
- UploadFile(path, data) - uploads a file with scaled timeout
- StopMedia() / StartMedia() - control media playback

These commands use the same 250-byte packet protocol as display operations.
File uploads write raw data directly to serial (not framed) after the
CreateFile command, with timeout scaled to file size for reliability.

Tested with the Shiny Snake G600 11.3" (Turing 10.2") panel which stores
images at /mnt/UDISK/img/.
@emaspa

emaspa commented Mar 7, 2026

Copy link
Copy Markdown
Contributor Author

Update: ReadStringResponse improvements

Following up on the ReadTo() timeout discussion, I've reworked ReadStringResponse to fix the storage management performance issues:

Problem: The original ReadResponse loop with a 5-second timeout blocked for the full duration waiting for bytes that never come, making storage operations very slow.

Solution: Rewrote ReadStringResponse with a looping read using short inter-read timeouts:

  • First read waits up to readTimeout (configurable per-call) for data to arrive
  • After first data arrives, switches to 50ms timeout for subsequent chunks
  • Stops when no more data within 50ms, avoids the long blocking wait

This matches the approach used by the ShinySnake/TURZX apps (RJCP.SerialPortStream with ReadTimeout=100ms and a single Read() call). The key insight is that the device sends responses quickly and completely, a short timeout is sufficient.

Additional changes in this update:

  • ReadTo() byte-by-byte reads cause timeouts on CDC ACM serial ports (CT13INCH) — kept as unused method for now, ReadStringResponse handles all storage responses
  • Added CancellationToken support to UploadFile with chunked writes (4KB) for cancellability
  • DiscardInBuffer() after upload/delete to prevent leftover data from corrupting subsequent responses
  • Increased timeouts for flash-dependent commands: CreateFile (5s), DeleteFile (5s), QueryStorageInfo (2s), ListDirectory (2s), upload completion (10s)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RevisionE: Add storage management commands

1 participant