SD Card Commands
Commands for SD card file operations. Requires __USE_SD_CARD__ feature enabled.
SD Card Support
Section titled “SD Card Support”The NanoVNA-H supports FAT-formatted SD cards for:
- Saving/loading calibration data
- Storing screenshots (BMP/TIFF)
- Saving measurement data (S1P/S2P)
- Loading command scripts
sd_list
Section titled “sd_list”List files on the SD card.
Syntax
Section titled “Syntax”sd_list [path]Parameters
Section titled “Parameters”| Parameter | Description |
|---|---|
path | Directory path (optional, default root) |
Output Format
Section titled “Output Format”<filename>.<ext> <size>Examples
Section titled “Examples”ch> sd_listCAL_001.CAL 6144SCREEN01.BMP 230454DATA0001.S2P 12345
ch> sd_list /dataSWEEP001.S1P 8192SWEEP002.S1P 8192- Filenames are 8.3 format (DOS-style)
- Directories shown without size
- Hidden/system files not shown
sd_read
Section titled “sd_read”Read and display file contents.
Syntax
Section titled “Syntax”sd_read <filename>Parameters
Section titled “Parameters”| Parameter | Description |
|---|---|
filename | File to read |
Examples
Section titled “Examples”ch> sd_read CONFIG.TXT# NanoVNA Configurationsweep 1M 100M 101power autobandwidth 1000
ch> sd_read DATA.S1P# Hz S RI R 501000000 0.998234 -0.0234562000000 0.997234 -0.024567Supported File Types
Section titled “Supported File Types”| Extension | Content |
|---|---|
.TXT | Plain text |
.CMD | Command script |
.S1P | Touchstone 1-port |
.S2P | Touchstone 2-port |
.CAL | Calibration data |
Binary Files
Section titled “Binary Files”Binary files (.BMP, .CAL) are output as raw bytes. Not recommended for direct viewing.
sd_delete
Section titled “sd_delete”Delete a file from the SD card.
Syntax
Section titled “Syntax”sd_delete <filename>Parameters
Section titled “Parameters”| Parameter | Description |
|---|---|
filename | File to delete |
Examples
Section titled “Examples”ch> sd_delete OLDCAL.CALdeleted
ch> sd_delete SCREEN01.BMPdeleted- No confirmation prompt
- Cannot delete directories
- Cannot recover deleted files
Display a message box on screen from a script (requires __SD_CARD_LOAD__).
Syntax
Section titled “Syntax”msg <delay> [text] [header]Parameters
Section titled “Parameters”| Parameter | Description |
|---|---|
delay | Display duration in milliseconds. Use 0 for indefinite (until touch) |
text | Message body text (optional) |
header | Message box title/header (optional) |
Examples
Section titled “Examples”ch> msg 3000 "Connect OPEN standard" "Calibration"ch> msg 5000 "Measurement complete"ch> msg 0 "Press screen to continue" "Paused"- Designed for use in
.CMDscript files to prompt the operator between steps - The message box blocks script execution until the delay expires or the user touches the screen
- With
delay 0, waits indefinitely for a touch event - Has
CMD_RUN_IN_LOADflag — available in script execution context
File Operations via Menu
Section titled “File Operations via Menu”The UI provides additional file operations not available via shell:
Saving Files
Section titled “Saving Files”Menu Path: SD CARD > Save options
| Option | Description |
|---|---|
SAVE S1P | Save S11 data as Touchstone |
SAVE S2P | Save S11+S21 as Touchstone |
SCREENSHOT | Save screen as BMP/TIFF |
SAVE CALIBRATION | Save calibration to file |
Loading Files
Section titled “Loading Files”Menu Path: SD CARD > LOAD
Browse and select files to load:
.CALfiles: Load calibration data.CMDfiles: Execute command script.S1P/.S2Pfiles: Import as stored trace
Command Scripts
Section titled “Command Scripts”Text files with .CMD extension can contain shell commands:
Script Format
Section titled “Script Format”# Comment linesweep 1M 100M 101cal open# wait for user to connect opencal short# wait for user to connect shortcal load# wait for user to connect loadcal donesave 0Running Scripts
Section titled “Running Scripts”Via menu: CONFIG > EXPERT SETTINGS > LOAD COMMAND SCRIPT
Script Commands
Section titled “Script Commands”Commands must have CMD_RUN_IN_LOAD flag set:
freq sweep power bandwidth saveconfig clearconfigcal save recall trace marker edelay s21offsetvbat tcxo reset smooth config usart_cfg usartvbat_offset transform threshold color measure pause resumeScript Notes
Section titled “Script Notes”- One command per line
- Lines starting with
#are comments - Blank lines are ignored
- No flow control (loops, conditionals)
- Maximum line length: 64 characters
File Formats
Section titled “File Formats”Touchstone S1P
Section titled “Touchstone S1P”! Comment# Hz S RI R 501000000 0.998234 -0.0234562000000 0.997234 -0.024567...Touchstone S2P
Section titled “Touchstone S2P”! Comment# Hz S RI R 501000000 0.998234 -0.023456 0.012345 0.001234 0.012345 0.001234 0.998234 -0.023456...Order: S11_re S11_im S21_re S21_im S12_re S12_im S22_re S22_im
Calibration File
Section titled “Calibration File”Binary format containing properties_t structure.
Screenshot BMP
Section titled “Screenshot BMP”Standard Windows BMP format:
- 16-bit RGB565 color
- No compression
- 320x240 or 480x320 pixels
Screenshot TIFF
Section titled “Screenshot TIFF”Uncompressed TIFF format:
- 16-bit RGB565 color
- IFD structure
SD Card Specifications
Section titled “SD Card Specifications”Supported Cards
Section titled “Supported Cards”| Type | Capacity | Notes |
|---|---|---|
| SD | Up to 2 GB | Best compatibility |
| SDHC | 4-32 GB | Supported |
| SDXC | 64+ GB | May not work |
File System
Section titled “File System”- FAT16 or FAT32
- 8.3 filename format
- Single partition
Connection
Section titled “Connection”| Signal | Pin |
|---|---|
| CS | PB11 |
| MOSI | PB5 (shared with LCD) |
| MISO | PB4 (shared with LCD) |
| SCLK | PB3 (shared with LCD) |
Troubleshooting
Section titled “Troubleshooting”Card Not Detected
Section titled “Card Not Detected”- Ensure card is FAT16/FAT32 formatted
- Try different card (some cards incompatible)
- Check card is fully inserted
- Clean contacts
File Access Errors
Section titled “File Access Errors”- Remove and reinsert card
- Check filename is 8.3 format
- Ensure sufficient free space
- Try reformatting card
Slow Operations
Section titled “Slow Operations”- SD operations share SPI with LCD
- Large files take time to transfer
- Sweep pauses during file access
Source Code Reference
Section titled “Source Code Reference”SD card commands in main.c:
cmd_sd_list: line 2814 (conditional:ENABLE_SD_CARD_COMMAND)cmd_sd_read: line 2832 (conditional:ENABLE_SD_CARD_COMMAND)cmd_sd_delete: line 2861 (conditional:ENABLE_SD_CARD_COMMAND)cmd_msg: line 2878 (conditional:__SD_CARD_LOAD__)
File system: FatFs/ff.c