# Data save :id=top

------

> _Doc Ver:_ 1.14  
_App Ver:_ 2.6.6.53  
_Date:_ 09/14/2026

------

> Save and convert SA1 real-time data. On-disk dialect: [Save protocol and integration](data-save-proto.md). Files live under the persist tree (`/home/debian/sa1/persist`, compat link `/var/sa/data`), not a separate RTLinux disk. All kinds share one name: `{idn}_{sn}-{kind}-{YYYYMMDD}_{HHMMSSNNN}[_{end_date}_{end_time}]` (equipment IDN/SN, not a save-page prefix). While writing: `{stem}.dat.temp`. After close, wl/pv become `{stem}.dat` or `{stem}.tar.gz`; raw becomes `.dat` or whole-file `.dat.gz` (not tar). Whether save slows demodulation, and how to keep save rate up with sample rate: [§6](#demod) and [Improve demodulator speed](improve_sa_speed.md).

------

## 1. Configure  :id=configure

> On-device storage is limited. Set row count, file size, and file count together against the free space.

  1.1. Check device storage

  * Menu > 'Monitor' > 'Service';
  * The bottom row of the monitor page shows built-in storage size.

  1.2. Save data on the device

  * Menu > 'Setting' > 'System' > 'Data save' or Menu > 'Data' > 'Realtime save' > 'Setting';
  * Set '1.2'–'1.6' from built-in storage and sample rate;
  * Check '1.8 Save wavelength' to write `persist/data/wl` (`0x00`, or `0x10` if 1.11 is 1). Check '1.9 Save physical value' to write `persist/data/pv` (`0x04`/`0x05`, or `0x15` if 1.11 is 1);
  * **1.6 Mode:** `0` normal — write wl/raw first, compute as usual, write pv after compute when 1.9 is on. `1` no compute — wl/raw only; ignores 1.9; list does not refresh. `2` full-speed sa-ds (see §2);
  * Upgrade maps old 0–4: `0` and `1` → `0`, old `2` → `1`, old `3` and `4` → `2`. Field Mode 1 becomes new `0`.
  * PV files closed under old Mode 1 **before 2.6.6.14** often have only a register (`0x21`) and export empty; they cannot be recovered. Use files written after that upgrade;
  * Check **1.10 Save raw** to write `persist/data/raw` as [SA_DATA_FILE v1.0](data-rawfile.md). Can run with wl/pv;
  * **1.11 Save protocol:** `0` original (SA1 default). `1` SA2 v1.7 on-disk: wavelength [`0x10`](data-wl-v1.7.md) absolute pm, physical [`0x15`](data-pv-v1.7.md). Live UDP **8190** and `:DATA:RAW?` stay original. Mode 2 sa-ds still writes original. Save then `:SYS:RELOAD`. Cookbook: [Save protocol and integration](data-save-proto.md).
  * Check '1.1 Enable';
  * Click 'Save' after changes, or 'Configure' if nothing changed. Save writes `/var/sa/conf/data_save.json` and reloads sa-di (`:SYS:RELOAD`).

  1.3. Send files off the device (csdfu)

  * Follow '1.2' so files exist on the device first;
  * Data save group **2** is bundled **csdfu** (service installed). Sending is YAML `enable` and Web 03 **Allow upload**, not a second install. Signed-in `/csdfu` → **:8787**. Page Help, `csdfu help`, and [Data file upload (csdfu)](dtfu.md) are the same facts.
  * Do not run two uploaders on the same data dir. Do not set csdfu source `max_files` (local retention stays on this page).

## 2. Full-speed save  :id=configure_fs

> For applications that need every resource for the highest sample and save rate.

  2.1. Check device storage

  * Menu > 'Monitor' > 'Service';
  * The bottom row of the monitor page shows built-in storage size.

  2.2. Save data on the device

  * Menu > 'Setting' > 'System' > 'Data save' or Menu > 'Data' > 'Realtime save' > 'Setting';
  * Basic settings: set '1.2'–'1.5' from built-in storage and sample rate;
  ```
    '1.2 Data rows': estimate file size from one frame; compressed files are about 1/10 of the source.
    '1.5 Buffer count': set to 5–10× the system sample rate.
  ```
  * High-speed setting: '1.6 Mode' = `2`. With 1.9 on, compute at '3.2' (old Mode 3). With 1.9 off, sa-di does not compute (old Mode 4);
  * Data-interface config: '3.1'–'3.10' are the high-speed settings;
  ```
   '3.1. Data interface count': how many high-speed interfaces are enabled. Later ports must be set in order; a middle port must not be empty.
   '3.2. Frequency': physical-value compute rate when Mode is 2 and 1.9 is on. Lower frequency disturbs high-speed collect/save less.
   '3.3'–'3.10': data-port command parameters:
        IDN(i): port identity.
        FileLable(l): file identity.
        Port(p): receive port.
        ChannelOffset(c): channel offset, default 0, for stacking devices into one system.
        WavelenghtOffset(w): wavelength offset, default 1510000 pm.
        Example:
        '-i DS1 -l 1 -p 8185 -c 0': ID 'DS1', file class '1', sample port '8185', channel offset '0' (none).
        '-i DS2 -l 2 -p 8186 -c 4': ID 'DS2', file class '2', sample port '8186', channel offset '4' (add 4 to every channel).
  ```
  * File compression: high-speed save produces a lot of data. Checking '1.7. Compress files' is recommended.
  * Click 'Save' after changes, or 'Configure' if nothing changed.

  2.3. Send files off the device (csdfu)

  * Same as §1.3. Full-speed files are still under `persist/data/`. Use csdfu, not sa-di upload.

## 3. Monitor  :id=monitoring

  3.1. Normal save

  * Menu > 'Monitor' > 'List';
  * The toolbar shows save controls: 'Pause', 'Save', plus 'Save counter' and 'Save rate'.
  * Menu > 'Service' also shows 'Save service', 'Save counter', and 'Save rate'.

  3.2. Full-speed save

  * Set Mode `2` under Menu > 'Data' > 'Realtime save' > 'Setting' (see §2). There is no separate Full-speed / Directory / Delete page; files and delete are on Menu > 'Monitor' > 'Data'.

## 4. Get saved data  :id=get

  * Menu > 'Monitor' > 'Data' (`/m/data.php`): left tree All / wl / pv / rt / raw / inbox, one table, search, batch Zip / CSV / delete, upload to `inbox/`.
  * Files land in `persist/data/wl` (0x00 or 0x10 wavelength), `persist/data/pv` (0x04/0x05 or 0x15 physical), and optionally `persist/data/raw/` (SA_DATA_FILE). Legacy `rt/` is listed read-only.
  * Status `open` is `{stem}.dat.temp` (still writing). Those rows have no download link; Zip / CSV / delete / unzip / play return 409.
  * CSV export on the Data page asks for `sa-file` kind (`auto` / `wl` / `pv` / `raw`) and compress (`zip` / `gz` / `none`). Multiple files always come back as zip.
  * On-device CSV uses `/var/sa/bin/sa-file` (no daemon). wl/pv `.tar.gz` and raw `.dat.gz` cannot play back until unzipped. Raw is never a `:PLAY` source.
  * Playback stays on sa-di `:PLAY:*` (not `sa-rdplay`). Only closed uncompressed `wl/`, `inbox/`, or old `rt/` `.dat` files. PV and raw do not play.
  * Format: [Save protocol and integration](data-save-proto.md) / [Binary extended data format](data-ext.md) / [physical-value frames](data-pv.md) / [SA2 v1.7 save](data-wl-v1.7.md) / [raw SA_DATA_FILE](data-rawfile.md)

## 5. Export saved data      :id=export

  5.1. On-device CSV (preferred)

  * Menu > 'Monitor' > 'Data'. Select **closed** files. CSV. Kind `auto` / `wl` / `pv` / `raw`. Compress `zip` / `gz` / `none`.
  * sa-web runs `/var/sa/bin/sa-file csv -s FILE -o DIR --kind …`. No daemon. Layout matches SA2 `file_processor` (not the old English long table).
  * Product kinds are only `wl` / `pv` / `raw`. Kind is hyphen-bounded in the name (`-wl-` / `-pv-` / `-raw-`).
  * Wavelength CSV: **no header**. One row per frame:

    `{YYYY-MM-DD HH:MM:SS}.{usec6},{unix}.{usec6},{counter},{ch},{wl},…`

    Only non-zero peaks. Original `0x00` stores `wl − 1_500_000`; export adds `1_500_000` (`%.6f`). SA2 `0x10` already stores absolute pm — do not add again.
  * Physical CSV: header once, then one row per frame (7-tuples sorted by ID):

    `ISO时间,Unix时间,计数器,ID,通道,错误码,波长,物理值,阈值报警,变化率报警`

    SA1 `0x04` has one alarm byte → 阈值报警; 变化率报警 is `0`. SA2 `0x15` fills both alarm columns. `sa-file` reads both dialects.
  * Raw CSV: `sec,nsec,src_port,ip,data_len,data_hex32`. See [raw file](data-rawfile.md).
  * CLI: `sa-file info FILE` then `sa-file csv -s FILE -o DIR --kind wl|pv|raw|auto`.

  5.2. Old Mode 1 PV files

  * Closed `pv/` files from **before 2.6.6.14** under Mode 1 are usually register-only (`sa-file info` → `frames=0`). Export is header-only. Re-save after the upgrade.

  5.3. Conversion tool saData (PC)

  * Optional desktop tool for historical / high-speed UDP files. On-device export does **not** need it.
  * LAN: http://192.168.3.9/sa/tools/saData/win32/latest
  * Historical tool host (not an SA1 install pack): http://112.74.80.60/sa/tools/saData/win32/latest
  * Download: saData-x.x.x.x.zip
  * Unpack. Copy files into saData's Data directory. Menu > 'Tools' > 'Data convert'.

## 6. Does save slow demodulation?  :id=demod

> Save is not “on means demod is blocked”. The three paths have very different cost. To raise sample rate or demod throughput, read [Improve demodulator speed](improve_sa_speed.md) first, then come back to these checkboxes.

  * **1.8 Wavelength wl:** separate save thread. Convert only signals “a frame is ready”. A slow disk drops **saved** frames; the list demod counters usually keep moving. The ring is small, so a slow write misses files — it does not lower hardware frequency by itself.
  * **1.9 Physical value pv:** in mode `0`, written on **the same thread that just computed**. On fat x86 (many cores, plenty of RAM), Mode 0 + wl + pv + zip and raw off usually shows no demod drop. On slow eMMC / low MHz, that `fwrite` delays compute. Mode `1` skips compute (ignores 1.9), so it is faster because there is **no PV**, not because one fewer file.
  * **1.10 Raw:** written on the UDP **8190** receive thread; rotate may gzip while holding the lock. **Worst for demod.** Leave off when you push sample rate. On only for a packet capture, and uncheck 1.7 if you can.
  * **1.7 Compress:** separate pack thread. Zip is fine on a fat box. On thin ARM / about 256 MB RAM, turn zip off first, then drop 1.9 or use mode `1`. Off-box send is **csdfu** (group 2 / `/csdfu`), not sa-di.
  * **1.4 Frequency = 0:** write as fast as demod, no extra interval. That is the save-side “keep up with sample rate” switch. It does **not** change the hardware sample rate on the Service page. A value `n` writes about n Hz: easier on disk, thinner files.
  * **1.6 Mode:** `0` daily (write first, then compute; with 1.9 on, write pv after compute). `1` when you only need wavelength files and want it faster. `2` full-speed sa-ds; in-box compute yields by default; with 1.9 on, compute at **3.2** — lower 3.2 to interfere less with high-rate save.
  * While tuning rate: 1.10 off; on a thin box also 1.7 off; if you do not need in-box PV, use mode `1` or uncheck 1.9. Full recipes: [Improve demodulator speed · save](improve_sa_speed.md#save).

## Change log :id=changelog

|Version|Date|Description|
|:--:|----|----------|
|1.14|09/14/2026|1. Point to integrator cookbook `data-save-proto` (live vs disk, CSV identity, troubleshooting).|
|1.13|09/14/2026|1. Item 1.11 Save protocol (`DS_SAVE_PROTO`): 0 original, 1 SA2 v1.7 on-disk. sa-file reads 0x10/0x15. Live stays original.|
|1.12|09/11/2026|1. §1.3 aligned with csdfu 0.2.6: Allow upload, three help surfaces, do not set source max_files.|
|1.11|09/09/2026|1. sa-di curl upload retired. Group 2 is bundled csdfu (service installed; send via YAML/Web).|
|1.10|09/08/2026|1. Added “Does save slow demodulation?”: wl / pv / raw paths, frequency 0, modes 0/1/2, link to Improve demodulator speed.|
|1.9|09/07/2026|1. Dropped Realtime-save menu items Full speed / Directory / Delete. Mode 2 stays in Setting; files/delete on Monitor > Data.|
|1.8|09/07/2026|1. Mode is three values: 0 normal (save first), 1 no compute, 2 full-speed sa-ds.|
|1.7|09/07/2026|1. Dropped Data format. Raw is only 1.10 Save raw. Mode is now 1.6.|
|1.6|09/07/2026|1. On-device CSV columns (SA2). Mode 1 writes pv/ after compute from 2.6.6.14. Old Mode 1 pv files stay empty.|
|1.5|09/07/2026|1. All files use `{idn}_{sn}-{kind}-…`; removed File prefix and PCB SN.|
|1.4|09/06/2026|1. Data page: one table + kind tree; CSV kind/compress; play still sa-di :PLAY.|
|1.3|09/06/2026|1. Page items 1.11/1.12 write wl/pv; Save reloads sa-di.|
|1.2|09/06/2026|1. Split wl/pv directories; Data page zip/CSV via sa-file.|
|1.1|06/04/2022|1. Added full-speed save notes.|
|1.0|08/02/2021|1. Help created for the new file format.|

------

[Top](#top)
