--- title: SSR Control Protocol Reference subtitle: Reference Manual models: SSR-1, SSR-1U, SSR-SDU firmware: "3.0" revision: "-" date: 2026-11-22 --- # Introduction The control protocol is a packet-based interface to the SSR serial data loggers. It gives a host computer or embedded controller the same control, status, and configuration functions as the interactive shell, plus access to the files on the logger's memory card, without parsing text. Every request from the host is answered: with the requested data, with an acknowledgement (ACK), or with a negative acknowledgement (NACK) that gives the reason for the failure. This document is the complete specification. It is written to be used on its own, by a person or by an AI coding assistant, to write a host in C, C++, Python, Arduino, or another language. Each message lists its exact payload, its replies, and its errors, and the examples are complete packets with correct checksums. ## About This Document This document describes the control protocol of firmware 3.0 on the models below. The SSR-LC does not have the control protocol. Table: Models With the Control Protocol | Model | Hardware | Channels | File access | Notes | |---|---|---|---|---| | SSR-1 | SSR1L | 1 – 3 | Yes | | | SSR-1 | SSR1 | 1 – 3 | No | Packets of at most 160 bytes ([Payload Count](#payload-count)) | | SSR-1U | SSR1U | 1 – 4 | Yes | | | SSR-SDU | SSRSDU | 1 – 4 | Yes | | The hardware name is shown by the shell `ver` command, and by [Unit Identity (0x28)](#unit-identity-0x28). Where a direction matters, the protocol is described from the logger's point of view: a *request* is sent by the host to the logger, and a *reply* is sent by the logger to the host. ## Related Documents Table: Related Documents | Document | Contents | |---|---| | User's Manual for your model | Hardware, connectors, recording functions, and specifications | | SSR Shell Reference | Every shell command, the configuration settings, and path templates | | AN003 – Card Access with ssrftp | Reading and writing the card from a PC with FileZilla, File Explorer, or any FTP client | | Flash Update Utility User's Guide | Updating the logger firmware | ## Conventions - Hexadecimal values have the prefix `0x`, as in `0x81`. Packet bytes are written in hexadecimal without the prefix, separated by spaces, as in `81 A1 24 00 24 48`. - Bits are numbered from 0 (least significant) to 7 (most significant). A range such as *bits 5–4* includes both bits. - Multi-byte values are sent most significant byte first (big endian). - *Logger* is the SSR; *host* is the computer or controller talking to it. - MUST, SHOULD, and MAY are used as in RFC 2119. # Using the Control Protocol ## Enabling the Control Channel The control protocol runs on one serial channel, in either of two ways: - **On the shell channel.** The shell channel accepts control protocol packets as well as typed commands, as shipped ([Control (0x45)](#control-0x45), the shell's `config control`). A host connects to the port a terminal would use, at the shell channel's settings, with no change of configuration. The packets are answered while the shell waits at its prompt; a packet sent while a shell command is running gets no reply. Only one program can open the port, so close the terminal program first. - **On a channel set to `control`.** The channel carries packets only: no shell banner, prompt, or echo. Use this for a channel that only a host uses. The shell, the control protocol, and the RecShell function share one user interface, so only one channel can be set to `shell`, `control`, or `recshell` at a time. To give the shell channel to the control protocol alone, set its function to `control`, save the configuration, and reset the logger. For channel 4: ```text >config 4 func control >config save >reset ``` After the reset, channel 4 accepts control protocol packets at its configured baud rate, parity, and stop bits. The same steps can be made with the control protocol itself ([Function (0x20)](#function-0x20)), so a host can return the channel to the shell when it is finished. > **Note:** A change to the function or line settings of the channel that carries the control protocol is stored at once but takes effect at the next reset. The host stays connected while it changes settings. The shell can still be reached when a channel is set to `control`: at power-up every channel briefly listens for the startup capture sequence described in the *SSR Shell Reference*, and a channel captured this way presents the shell until the next reset. ## Serial Settings The control protocol uses the settings of the channel it runs on: a baud rate from 600 up to the logger's maximum (230400 on standard models, 921600 on high-speed models), 8 data bits, no, odd, or even parity, and 1, 1.5 or 2 stop bits. The protocol is binary: use 8 data bits. The factory setting of every channel is 115200 baud, 8 data bits, no parity, 1 stop bit. There is no command that changes the baud rate for a transfer: set the channel to the rate the host will use beforehand. ## Message Exchange 1. The host starts every exchange. Send one request, wait for its reply, then send the next. [Stream Blocks (0x6E)](#stream-blocks-0x6e-and-stop-stream-0x6f) is the one request answered by several packets. 2. Every request gets exactly one reply: data, an ACK or a NACK. 3. A packet with a bad checksum is discarded without a reply. Treat a missing reply as a lost packet and send the request again, after the time given in [Timing](#timing). 4. A packet that stops part way is discarded by the logger when no byte has arrived for 100 ms. The logger then waits for a new start sequence. Send each packet in one write, so that its bytes follow each other without a pause. 5. Bytes that are not part of a packet are ignored by the control protocol (on the shell channel they go to the shell). The host SHOULD likewise ignore anything that is not a packet, such as the text the logger prints at power-up. 6. Status and other data messages are polled: the host sends the message ID with no payload, and the logger replies with the same ID and the data. ## Timing Table: Reply Times | Request | Typical | Allow before retrying | |---|---|---| | Most requests | under 10 ms | 1 s | | The first card access after the card is inserted or the logger starts | up to 1 s | 2 s | | Disk Status on a large card | up to a few seconds | 5 s | | Delete, Rename, Make Directory, Open File with create, in a directory with many entries | up to a few seconds | 5 s | | Card Eject, Card Mount | usually a fraction of a second; the logger waits at most 10 s, then replies NACK 23 | 12 s | | Between the packets of a stream | about one packet time (11 ms at 921600 baud) | 1 s | ## A First Exchange Polling the firmware version is a simple way to check that the host and the logger are communicating. The host sends Firmware Version (`0x26`) with no payload: ```text Host: 81 A1 26 00 26 4C Logger: 81 A1 26 05 33 2E 30 2E 30 1A FB ``` The reply carries five payload bytes, the ASCII text `3.0.0`. # Packets ## Packet Structure Every message, in either direction, is one packet: Table: Packet Structure | Field | Bytes | Content | |---|---|---| | Start | 2 | `0x81 0xA1` | | ID | 1 | Message ID ([Message Summary](#message-summary)) | | Count | 1 | Payload length code ([Payload Count](#payload-count)) | | Payload | 0 to 1144 | Message data | | Cksum1, Cksum2 | 2 | Fletcher checksum over ID, Count, and Payload ([Checksum](#checksum)) | ## Payload Count - Count `0x00` to `0x7F`: the payload is that many bytes, 0 to 127. - Count `0x80` to `0xFF`: the payload is `128 + (Count & 0x7F) * 8` bytes, 128 to 1144 in steps of 8. A payload of more than 127 bytes therefore always has a length that is a multiple of 8, and a sender pads a longer payload with extra bytes up to the next multiple of 8. The pad bytes are covered by the checksum, but a receiver MUST NOT treat them as data: every message that can be longer than 127 bytes carries the length of its data in a length field, or ends its strings with `0x00`. Senders SHOULD pad with `0x00`; the logger does. Example: a payload of 1030 bytes is sent as 1032 bytes (two pad bytes), with Count = `0x80 | ((1032 - 128) / 8)` = `0xF1`. > **Note:** The SSR-1 on SSR1 hardware accepts packets of at most 160 bytes in total: a payload of up to 154 bytes. Every message it supports fits. A longer packet is discarded without a reply. ## Checksum The checksum is a Fletcher checksum (RFC 1145) over the ID, Count, and Payload bytes, including any pad bytes. It does not include the start bytes. Both sums are 8-bit values that wrap around: ```c unsigned char c1 = 0, c2 = 0; const unsigned char *p = &packet[2]; /* the ID byte */ for (int i = 0; i < padded_payload_length + 2; ++i) { c1 = (unsigned char)(c1 + p[i]); c2 = (unsigned char)(c2 + c1); } /* append c1, then c2 */ ``` Worked example, the ACK of a Record request: ID `0x90`, Count `0x01`, Payload `0x10`. Table: Checksum Example | Byte | Value | c1 | c2 | |:---:|:---:|:---:|:---:| | ID | 0x90 | 0x90 | 0x90 | | Count | 0x01 | 0x91 | 0x21 | | Payload | 0x10 | 0xA1 | 0xC2 | The complete packet is `81 A1 90 01 10 A1 C2`. ## Data Types Table: Data Types | Type | Description | |---|---| | U1, U2, U4, U8 | Unsigned integer of 1, 2, 4 or 8 bytes, big endian | | STR | A path or name: bytes ending with `0x00`. Characters are 8-bit (code page 437); use printable ASCII for portability. | | TEXT | ASCII text with no ending `0x00`; its length is the payload length | | DATA[n] | n bytes of file data, n given by a length field | ## Acknowledgements A request that is carried out and has no data to return is answered with an ACK. A request that cannot be carried out is answered with a NACK, which gives the reason as an [error code](#error-codes). Table: ACK and NACK | Packet | ID | Payload | |---|---|---| | ACK | `0x90` | U1 ID of the request | | NACK | `0x91` | U1 ID of the request, U1 error code | The ACK of a Record request (ID `0x10`), and a NACK of a Record request that gave an invalid channel number (error code 2): ```text ACK: 81 A1 90 01 10 A1 C2 NACK: 81 A1 91 02 10 02 A5 6C ``` Configuration requests are acknowledged with the ID of the configuration message, `0x50` or `0x51`, not the configuration item ([Configuration](#configuration)). A data message polled with a payload is an error: the logger replies NACK with error code 1, `NACK_INV_LEN`. # Message Summary Table: Control Protocol Messages | ID | Message | Request payload | Reply | |---|---|---|---| | `0x10` | [Record](#record-0x10) | U1 channel, optional path template | ACK | | `0x11` | [Stop](#stop-0x11) | U1 channel | ACK | | `0x12` | [Card Eject](#card-eject-0x12-and-card-mount-0x13) | none | ACK | | `0x13` | [Card Mount](#card-eject-0x12-and-card-mount-0x13) | none | ACK | | `0x20` | [Command Status](#command-status-0x20) | none | 5 bytes | | `0x21` | [Card Status](#card-status-0x21) | none | 1 byte | | `0x22` | [Disk Status](#disk-status-0x22) | none | 8 bytes | | `0x23` | [Channel Status](#channel-status-0x23) | U1 channel | 2 bytes | | `0x24` | [All Channel Status](#all-channel-status-0x24) | none | 1 byte per channel | | `0x25` | [RTC Battery](#rtc-battery-0x25) | none | 2 bytes | | `0x26` | [Firmware Version](#firmware-version-0x26) | none | TEXT | | `0x27` | [File Access Information](#file-access-information-0x27) | none | 8 bytes | | `0x28` | [Unit Identity](#unit-identity-0x28) | none | TEXT | | `0x30` | [Date](#date-0x30) | none, or the date to set | 7 bytes, or ACK | | `0x31` | [Time](#time-0x31) | none, or the time to set | 5 bytes, or ACK | | `0x50` | [Configuration Set](#configuration) | U1 item, then the item's data | ACK | | `0x51` | [Configuration Query](#configuration) | U1 item, then U1 channel for a channel item | The item's value | | `0x60` | [Change Directory](#change-directory-0x60) | STR path | ACK | | `0x61` | [Make Directory](#make-directory-0x61) | STR path | ACK | | `0x62` | [Delete](#delete-0x62) | STR path | ACK | | `0x63` | [Current Directory](#current-directory-0x63) | none | STR path | | `0x64` | [Directory First](#directory-first-0x64-and-directory-next-0x65) | STR path, or none | An entry, or empty | | `0x65` | [Directory Next](#directory-first-0x64-and-directory-next-0x65) | none | An entry, or empty | | `0x66` | [Open File](#open-file-0x66) | U1 mode, STR path | ACK | | `0x67` | [Close File](#close-file-0x67) | none | ACK | | `0x68` | [Write Data](#write-data-0x68) | U2 n, DATA[n] | ACK | | `0x69` | [Read Data](#read-data-0x69) | U2 n | U2 got, DATA[got] | | `0x6A` | [Sync File](#sync-file-0x6a) | none | ACK | | `0x6B` | [Seek](#seek-0x6b) | U8 offset | ACK | | `0x6C` | [Position](#position-0x6c) | none | U8 offset | | `0x6D` | [Rename](#rename-0x6d) | STR from, STR to | ACK | | `0x6E` | [Stream Blocks](#stream-blocks-0x6e-and-stop-stream-0x6f) | U4 first block, U2 count | Block packets | | `0x6F` | [Stop Stream](#stream-blocks-0x6e-and-stop-stream-0x6f) | none | ACK | | `0x90` | [ACK](#acknowledgements) | | | | `0x91` | [NACK](#acknowledgements) | | | | `0x99` | [Reset](#reset-0x99) | none | ACK, then reset | Every request can also be answered with a NACK. An ID not in this table is answered with NACK code 25, `NACK_UNKNOWN`. Messages `0x70` to `0x7F` are reserved for later file-access additions. On SSR1 hardware, `0x60` to `0x6F` are answered with `NACK_UNKNOWN`. # Control Messages ## Record (0x10) Starts recording on a channel. The channel's command source is set to software (`+soft`) and its soft command to *record*. A path template can be sent with the request; it replaces the channel's path template before the file is opened. #### Request | Offset | Type | Name | Description | |---|---|---|---| | 0 | U1 | channel | Channel number, 1 to 3 (SSR-1) or 1 to 4 (SSR-1U, SSR-SDU) | | 1 | TEXT | path | Optional. Path template, ASCII, no ending `0x00`. Up to 44 characters (29 on SSR1 hardware) | #### Reply ACK, or NACK: - 1 `NACK_INV_LEN` – no payload - 2 `NACK_INV_CH` – invalid channel number - 12 `NACK_PATH_LEN` – the path template is too long - 13 to 16 – the path template is not valid ([Error Codes](#error-codes)) - 34 `NACK_NOT_RECORD` – the channel's function is not `record` or `recshell` #### Notes - Command source, soft command, and path template are changed in the working configuration. They are kept after a reset only if the configuration is saved ([Load, Save, and Erase](#load-save-and-erase-0x01--0x03)). - With a sequence field in the template, or in *retry* file mode when the file exists, the file opened has a different name from the first one tried. Poll [Channel Status](#channel-status-0x23) to see whether recording has started. #### Example Start recording on channel 2 with the path template `run[ymd].dat`: ```text Host: 81 A1 10 0D 02 72 75 6E 5B 79 6D 64 5D 2E 64 61 74 DD A4 Logger: 81 A1 90 01 10 A1 C2 ``` ## Stop (0x11) Stops recording on a channel. The channel's command source is set to software (`+soft`) and its soft command to *stop*. The file being written is closed. #### Request | Offset | Type | Name | Description | |---|---|---|---| | 0 | U1 | channel | Channel number | #### Reply ACK, or NACK 1 `NACK_INV_LEN` or 2 `NACK_INV_CH`. ```text Host: 81 A1 11 01 01 13 36 Logger: 81 A1 90 01 11 A2 C3 ``` ## Card Eject (0x12) and Card Mount (0x13) Card Eject does what the shell `card eject` does: recording stops, every file closes, and the card is unmounted and powered off, so that it can be removed safely. Card Mount ends an eject: the card is powered and mounted again, and recording resumes according to each channel's command source. A card that is taken out and put back after an eject is also mounted again. #### Request No payload. Each usually takes a fraction of a second. The logger waits at most 10 s for the files to close (eject) or the card to mount (mount); if that is not done by then, it replies NACK 23. #### Reply ACK when the card is ejected or mounted, also when it already was. Or NACK: - 1 `NACK_INV_LEN` – a payload was sent - 19 `NACK_SD_NOT_READY` – no card - 29 `NACK_ACCESS_DENIED` – USB has the card (SSR-1U, SSR-SDU) - 23 `NACK_SD_TIMEOUT` – the files did not close (eject) or the card did not mount (mount) within 10 s ```text Host: 81 A1 12 00 12 24 Logger: 81 A1 90 01 12 A3 C4 ``` ## Reset (0x99) Resets the logger. The logger sends an ACK, waits about 20 ms so that the ACK is sent, and resets. Recording stops as it does when power is removed, and changes that were not saved are lost. After the reset the logger starts with its saved configuration. #### Request No payload. #### Reply ACK, or NACK 1 `NACK_INV_LEN` if a payload was sent. ```text Host: 81 A1 99 00 99 32 Logger: 81 A1 90 01 99 2A 4B ``` # Status Messages The status messages are polled: send the ID with no payload ([Channel Status](#channel-status-0x23) takes a channel number). A payload with any other status request is answered with NACK 1 `NACK_INV_LEN`. ## Command Status (0x20) Reports the soft command of each channel and the state of the digital (DI) and pulse (PI) record inputs. #### Reply | Offset | Type | Name | Description | |---|---|---|---| | 0 | U1 | status | Bit 7: channel 4 soft command (0 on the SSR-1)
Bit 6: channel 3 soft command
Bit 5: channel 2 soft command
Bit 4: channel 1 soft command
Bit 3: PWM state latched (a 1 ms or 2 ms pulse seen since power-up)
Bit 2: PWM input valid now
Bit 1: PWM state is 2 ms (0: 1 ms, or not latched)
Bit 0: digital input DI is high | | 1 | U2 | width | PWM pulse width, µs; 0 with no signal | | 3 | U2 | period | PWM period, µs; 0 with no signal | A soft command bit is 1 when the channel's soft command is *record*. It decides recording when the channel's command source is `+soft` or `-soft`. Bits 3 and 1 are the PWM state, which decides recording when the channel's command source is `+pwm` or `-pwm`. The state changes only on a valid pulse within 250 µs of 1 ms or 2 ms, and it holds when the signal goes, so a loose connection does not stop recording. Bit 2 is the input now: 1 while valid pulses arrive (width 750–2250 µs, period 4–65 ms), 0 with no signal or a signal outside those limits. The input reads as no signal 65 ms after the last pulse, and width and period then read 0. | Bit 3 | Bit 1 | PWM state | |---|---|---| | 0 | 0 | not latched: no 1 ms or 2 ms pulse since power-up. A `+pwm` or `-pwm` channel does not record. | | 1 | 0 | 1 ms: a `-pwm` channel records | | 1 | 1 | 2 ms: a `+pwm` channel records | Channel 1 soft command set, a valid 1.5 ms pulse every 20 ms on PI (too far from 1 ms or 2 ms to set the state), DI low: ```text Host: 81 A1 20 00 20 40 Logger: 81 A1 20 05 14 05 DC 4E 20 88 C6 ``` ## Card Status (0x21) Reports the state of the memory card as seen by the card socket and driver. #### Reply | Offset | Type | Name | Description | |---|---|---|---| | 0 | U1 | status | Bits 7–3: reserved, 0
Bit 2: card is write protected
Bit 1: no card in the socket
Bit 0: card is not initialized | A value of `0x00` means a card is present and ready. ## Disk Status (0x22) Reports the size of the card's file system and the free space. #### Reply | Offset | Type | Name | Description | |---|---|---|---| | 0 | U4 | size | Size of the file system, kB | | 4 | U4 | free | Free space, kB | If the file system cannot be read, the reply is a NACK with a code from 17 to 24 ([Error Codes](#error-codes)). Code 19, `NACK_SD_NOT_READY`, means no card is present or it is not initialized. A card of 15,532,032 kB (about 15.9 GB) with 13,631,488 kB free: ```text Host: 81 A1 22 00 22 44 Logger: 81 A1 22 08 00 ED 00 00 00 D0 00 00 E7 87 ``` ## Channel Status (0x23) Reports one channel's status byte: the byte [All Channel Status](#all-channel-status-0x24) gives for that channel. #### Request | Offset | Type | Name | Description | |---|---|---|---| | 0 | U1 | channel | Channel number | #### Reply | Offset | Type | Name | Description | |---|---|---|---| | 0 | U1 | channel | The channel number from the request | | 1 | U1 | status | The [channel status byte](#channel-status-byte) | A host MUST accept and ignore bytes after the status byte: later firmware may add them. NACKs: 1 `NACK_INV_LEN`, 2 `NACK_INV_CH`. Channel 1, recording: ```text Host: 81 A1 23 01 01 25 6C Logger: 81 A1 23 02 01 93 B9 27 ``` ## All Channel Status (0x24) Reports the function and recording state of every channel: one status byte per channel, 3 bytes on the SSR-1 and 4 on the SSR-1U and SSR-SDU. #### Reply | Offset | Type | Name | Description | |---|---|---|---| | 0 | U1 | channel 1 | Status of channel 1 | | 1 | U1 | channel 2 | Status of channel 2 | | 2 | U1 | channel 3 | Status of channel 3 | | 3 | U1 | channel 4 | Status of channel 4 (SSR-1U and SSR-SDU) | ### Channel Status Byte Table: Channel Status Byte | Bits | Meaning | |---|---| | 7 | Record commanded: the channel's command source is asking it to record. It can be 1 while the channel is not recording, for example with no card; bits 3–0 give the reason. | | 6–4 | Active function: 0 disabled, 1 record, 2 control, 3 shell, 4 RecShell | | 3–0 | File state: 0 closed, 1 building path, 2 opening file, 3 recording, 4 path template translation error, 5 error building path, 6 error opening file, 7 disk error, 8 disk full, 9 USB has the card (SSR-1U, SSR-SDU) | The active function is the function in use now. It can differ from the configured function until the next reset ([Enabling the Control Channel](#enabling-the-control-channel)). On an SSR-1U, channel 1 recording, channel 2 set to record but not commanded, channel 3 disabled, channel 4 the control channel: ```text Host: 81 A1 24 00 24 48 Logger: 81 A1 24 04 93 10 00 20 EB 88 ``` ## RTC Battery (0x25) Reports the voltage of the real-time clock's backup battery. #### Reply | Offset | Type | Name | Description | |---|---|---|---| | 0 | U2 | voltage | Battery voltage, mV | A value below 1000 mV means no battery is fitted; the shell `status` command shows *none*. ```text Host: 81 A1 25 00 25 4A Logger: 81 A1 25 02 0B B8 EA 68 ``` ## Firmware Version (0x26) Reports the firmware version as TEXT, for example `3.0.0` ([A First Exchange](#a-first-exchange)). #### Reply | Offset | Type | Name | Description | |---|---|---|---| | 0 | TEXT | version | Firmware version | ## Unit Identity (0x28) Reports what the shell `ver` command shows: the firmware, the build, and the unit's identity, as TEXT lines that each end with CR LF. #### Reply | Offset | Type | Name | Description | |---|---|---|---| | 0 | TEXT | identity | The lines below, each ending with `0x0D 0x0A` | Table: Unit Identity Lines | Line | Content | |---|---| | `Firmware: ` | Firmware version | | `Build: ` | Build date and time | | `MK: ` | Make: Slerj | | `HW: ` | Hardware: SSR1, SSR1L, SSR1U, or SSRSDU | | `MG: ` | Manufacturing number | | `MD: ` | Model | | `SN: ` | Serial number | | `MV: ` | Model variant, the part number suffix. An `H` marks a high-speed unit. | | `Max Baud: ` | The highest baud rate the unit accepts, and why | A field that is not programmed reads `-`. The reply is usually longer than 127 bytes, so it is padded with `0x00` ([Payload Count](#payload-count)): the text ends at the last CR LF. ```text Firmware: 3.0.0 Build: Oct 28 2026 21:28:31 MK: Slerj HW: SSR1U MG: 6539453 MD: SSR-1U SN: 656 MV: 22T Max Baud: 236000 (standard) ``` ## File Access Information (0x27) Reports whether this logger has [file access](#file-access), and its data sizes. #### Reply | Offset | Type | Name | Description | |---|---|---|---| | 0 | U1 | version | 1 for this document | | 1 | U1 | flags | Bit 0: file access (`0x60`–`0x6D`) available
Bit 1: streaming (`0x6E`, `0x6F`) available
Other bits 0 | | 2 | U2 | read size | Most data in one Read Data reply; also the Stream Blocks block size (1024) | | 4 | U2 | write size | Most data in one Write Data request (1024) | | 6 | U2 | max path | Longest path, in bytes, including the ending `0x00` (126) | Flags 0 means no file access (SSR1 hardware; the sizes are then 0). A logger that answers `NACK_UNKNOWN` (firmware before 3.0) has no file access as described here. ```text Host: 81 A1 27 00 27 4E Logger: 81 A1 27 08 01 03 04 00 04 00 00 7E B9 91 ``` Version 1, flags `0x03`, read size 1024, write size 1024, max path 126. # Date and Time Date and Time set or read the real-time clock. A request with no payload reads the current value; a request with a payload sets it. The clock keeps the local time set by the user; it is not adjusted for daylight saving time. When the clock is set, every channel recording a time tagged archive gets a new time correlation packet, so the archive's time stamps follow the new time. ## Date (0x30) #### Set request | Offset | Type | Name | Description | |---|---|---|---| | 0 | U2 | year | Year, 2001 to 2099 | | 2 | U1 | month | Month, 1 to 12 | | 3 | U1 | day | Day of the month, 1 to 31 | ACK, or NACK 1 `NACK_INV_LEN` or 4 `NACK_INV_DATE`. The date must be a real calendar date: 29 February only in a leap year. #### Poll reply | Offset | Type | Name | Description | |---|---|---|---| | 0 | U2 | year | Year, 2001 to 2099 | | 2 | U1 | month | Month, 1 to 12 | | 3 | U1 | day | Day of the month, 1 to 31 | | 4 | U2 | doy | Day of the year, 1 to 366 | | 6 | U1 | weekday | Day of the week, 0 Sunday to 6 Saturday | Set the date to 20 October 2026, then poll it. The reply gives day of year 293 (`0x0125`) and weekday 2, a Tuesday: ```text Host: 81 A1 30 04 07 EA 0A 14 43 36 Logger: 81 A1 90 01 30 C1 E2 Host: 81 A1 30 00 30 60 Logger: 81 A1 30 07 07 EA 0A 14 01 25 02 6E 66 ``` ## Time (0x31) #### Set request | Offset | Type | Name | Description | |---|---|---|---| | 0 | U1 | hour | Hour, 0 to 23 | | 1 | U1 | minute | Minute, 0 to 59 | | 2 | U1 | second | Second, 0 to 59 | ACK, or NACK 1 `NACK_INV_LEN` or 5 `NACK_INV_TIME`. #### Poll reply | Offset | Type | Name | Description | |---|---|---|---| | 0 | U1 | hour | Hour, 0 to 23 | | 1 | U1 | minute | Minute, 0 to 59 | | 2 | U1 | second | Second, 0 to 59 | | 3 | U2 | msec | Milliseconds, 0 to 999 | Set the time to 14:30:00, then poll it a few seconds later: ```text Host: 81 A1 31 03 0E 1E 00 60 67 Logger: 81 A1 90 01 31 C2 E3 Host: 81 A1 31 00 31 62 Logger: 81 A1 31 05 0E 1E 05 01 F4 5C 38 ``` # Configuration ## Configuration Set and Query Every setting of the shell `config` command is reached with two messages: - **Configuration Set (`0x50`)** carries an action or a new setting. The first payload byte is the *configuration ID* (CID) of the item. The logger replies ACK or NACK with message ID `0x50`. - **Configuration Query (`0x51`)** reads a setting. The logger replies with message ID `0x51` carrying the item's value, or NACK with message ID `0x51`. Changes are made to the working configuration and take effect at once, except the line settings and function of the control channel ([Enabling the Control Channel](#enabling-the-control-channel)). Save ([Load, Save, and Erase](#load-save-and-erase-0x01--0x03)) keeps the working configuration across a reset. Each item is one of three kinds, shown in the *Kind* column of the table below: - **action**: Load, Save, and Erase act on the whole configuration ([Load, Save, and Erase](#load-save-and-erase-0x01--0x03)). - **channel**: the item applies to one channel, which the payload names ([Channel Items](#channel-items)). - **global**: the item applies to the whole logger ([Global Items](#global-items)). Table: Configuration IDs | CID | Item | Kind | Set data after the CID | |---|---|---|---| | `0x01` | [Load](#load-save-and-erase-0x01--0x03); query: stored configuration valid | action | none | | `0x02` | [Save](#load-save-and-erase-0x01--0x03) | action | none | | `0x03` | [Erase](#load-save-and-erase-0x01--0x03) | action | none | | `0x10` | [Line](#line-0x10) | channel | U1 channel, U1 line, U2 baud/100 | | `0x11` | [Baud](#baud-0x11) | channel | U1 channel, U2 baud/100 | | `0x12` | [Parity](#parity-0x12) | channel | U1 channel, U1 parity | | `0x13` | [Stop Bits](#stop-bits-0x13) | channel | U1 channel, U1 stop | | `0x14` | [Data Bits](#data-bits-0x14) | channel | U1 channel, U1 bits | | `0x15` | [Echo](#echo-0x15) | channel | U1 channel, U1 echo | | `0x20` | [Function](#function-0x20) | channel | U1 channel, U1 function | | `0x21` | [Command Source](#command-source-0x21) | channel | U1 channel, U1 source | | `0x22` | [Soft Command](#soft-command-0x22) | channel | U1 channel, U1 command | | `0x30` | [File Type](#file-type-0x30) | channel | U1 channel, U1 type | | `0x31` | [File Mode](#file-mode-0x31) | channel | U1 channel, U1 mode | | `0x33` | [File Path](#file-path-0x33) | channel | U1 channel, TEXT path template | | `0x34` | [File Size](#file-size-0x34) | channel | U1 channel, U1 size | | `0x40` | [Status Outputs](#status-outputs-0x40) | global | U1 mode | | `0x41` | [TL Timestamps](#tl-timestamps-0x41) | global | U1 format | | `0x42` | [LEDs](#leds-0x42) | global | U1 operation | | `0x43` | [Pin 19](#pin-19-0x43) | global | U1 function | | `0x44` | [USB Enable](#usb-enable-0x44) | global | U1 condition (SSR-1U, SSR-SDU) | | `0x45` | [Control](#control-0x45) | global | U1 on | Any other CID is answered with NACK 25 `NACK_UNKNOWN`; so is `0x44` on the SSR-1. ## Load, Save, and Erase (0x01 – 0x03) These Set items take no data: the payload is the CID alone. Table: Load, Save, and Erase | CID | Action | Description | |---|---|---| | `0x01` | Load | Replaces the working configuration with the saved configuration. NACK 3 `NACK_INV_NV` if no valid configuration is saved. | | `0x02` | Save | Saves the working configuration. | | `0x03` | Erase | Erases the saved configuration. The working configuration is not changed; the factory defaults are used from the next reset. | Query of CID `0x01` (payload: CID only) replies U1 CID, U1 valid: 1 if a valid saved configuration was loaded at startup, 0 if the factory defaults are in use. `0x02` and `0x03` cannot be queried. ```text Host: 81 A1 50 01 02 53 F4 Logger: 81 A1 90 01 50 E1 02 Host: 81 A1 51 01 01 53 F6 Logger: 81 A1 51 02 01 01 55 4D ``` ## Channel Items A channel item applies to one channel. Table: Channel Item Layouts | Message | Payload | |---|---| | Set request (`0x50`) | U1 CID, U1 channel, value | | Query request (`0x51`) | U1 CID, U1 channel | | Query reply (`0x51`) | U1 CID, U1 channel, value | Errors common to channel items: 1 `NACK_INV_LEN` (the payload is not the length the item needs), 2 `NACK_INV_CH` (invalid channel number). Set the baud rate of channel 2 to 115200 (baud/100 = 1152 = `0x0480`), then read it back: ```text Host: 81 A1 50 04 11 02 04 80 EB C6 Logger: 81 A1 90 01 50 E1 02 Host: 81 A1 51 02 11 02 66 6E Logger: 81 A1 51 04 11 02 04 80 EC CC ``` ### Line (0x10) The baud rate, data bits, parity, and stop bits of a channel in one item. | Offset | Type | Name | Description | |---|---|---|---| | 2 | U1 | line | Bits 7–6: parity, 0 none, 1 odd, 2 even
Bits 5–4: stop bits, 0 = 1, 1 = 1.5, 2 = 2
Bit 3: data bits, 0 = 8, 1 = 7
Bits 2–0: reserved, 0 | | 3 | U2 | baud | Baud rate divided by 100 | More NACKs: 6 `NACK_INV_BAUD`, 7 `NACK_INV_PARITY`, 8 `NACK_INV_STOP`. On SSR1 hardware, 7 data bits with no parity is not supported (NACK 7). ### Baud (0x11) | Offset | Type | Name | Description | |---|---|---|---| | 2 | U2 | baud | Baud rate divided by 100, for example 1152 for 115200 | The rate must be from 600 to the logger's maximum: 236000 on standard units (covers 230400), 944000 on high-speed units (covers 921600). [Unit Identity](#unit-identity-0x28) gives the maximum. More NACKs: 6 `NACK_INV_BAUD`. ### Parity (0x12) | Offset | Type | Name | Description | |---|---|---|---| | 2 | U1 | parity | 0 none, 1 odd, 2 even | More NACKs: 7 `NACK_INV_PARITY`. On SSR1 hardware, no parity is refused while the channel has 7 data bits. ### Stop Bits (0x13) | Offset | Type | Name | Description | |---|---|---|---| | 2 | U1 | stop | 0 = 1 stop bit, 1 = 1.5, 2 = 2 | More NACKs: 8 `NACK_INV_STOP`. ### Data Bits (0x14) | Offset | Type | Name | Description | |---|---|---|---| | 2 | U1 | bits | 0 = 8 data bits, 1 = 7 data bits | More NACKs: 7 `NACK_INV_PARITY` on SSR1 hardware, for 7 data bits while the channel's parity is none. ### Echo (0x15) When echo is on, the channel sends each byte it receives back out on its transmit line. | Offset | Type | Name | Description | |---|---|---|---| | 2 | U1 | echo | 0 off, 1 on | More NACKs: 33 `NACK_BAD_PARAM` for a value above 1. ### Function (0x20) | Offset | Type | Name | Description | |---|---|---|---| | 2 | U1 | function | 0 disabled, 1 record, 2 control, 3 shell, 4 RecShell | Only one channel can be control, shell, or RecShell. A RecShell channel needs something that can request its shell: pin 19 set to *shell* ([Pin 19](#pin-19-0x43)) on any channel, or, on the SSR-SDU, channel 4 itself, whose shell is requested by power on the channel 4 connector. The query gives the configured function; [Channel Status](#channel-status-0x23) gives the active one. More NACKs: - 9 `NACK_SHCTRL_TAKEN` – another channel is already control, shell, or RecShell - 33 `NACK_BAD_PARAM` – a value above 4 - 36 `NACK_P19_NEEDED` – RecShell, with nothing to request the shell: set pin 19 to *shell* first Return the user interface to the shell on channel 4, save, and reset: ```text Host: 81 A1 50 03 20 04 03 7A 07 Logger: 81 A1 90 01 50 E1 02 Host: 81 A1 50 01 02 53 F4 Logger: 81 A1 90 01 50 E1 02 Host: 81 A1 99 00 99 32 Logger: 81 A1 90 01 99 2A 4B ``` ### Command Source (0x21) What commands a record channel to record. | Offset | Type | Name | Description | |---|---|---|---| | 2 | U1 | source | 0 `+soft`, 1 `-soft`, 2 `+dig`, 3 `-dig`, 4 `+pwm`, 5 `-pwm` | Table: Command Sources | Value | Shell | The channel records when | |---|---|---| | 0 | `+soft` | the soft command is *record*. It is set to *record* at startup, so the channel records from power-up. | | 1 | `-soft` | the soft command is *record*. It is set to *stop* at startup. | | 2 | `+dig` | the digital input DI is high | | 3 | `-dig` | the digital input DI is low (factory setting) | | 4 | `+pwm` | the pulse input PI carries 2 ms pulses; 1 ms pulses stop recording | | 5 | `-pwm` | the pulse input PI carries 1 ms pulses; 2 ms pulses stop recording | More NACKs: 10 `NACK_INV_SOURCE`. ### Soft Command (0x22) | Offset | Type | Name | Description | |---|---|---|---| | 2 | U1 | command | 0 stop, 1 record | The soft command decides recording when the command source is `+soft` or `-soft`. [Record](#record-0x10) and [Stop](#stop-0x11) set the command source and the soft command in one step. ### File Type (0x30) | Offset | Type | Name | Description | |---|---|---|---| | 2 | U1 | type | 0 raw, 1 time tagged (`tt`), 2 tagged line (`tl`) | More NACKs: 33 `NACK_BAD_PARAM` for a value of 3. The file types are described in the user's manual. ### File Mode (0x31) | Offset | Type | Name | Description | |---|---|---|---| | 2 | U1 | mode | 0 retry, 1 append, 2 overwrite | More NACKs: 11 `NACK_INV_FM`. ### File Path (0x33) The path template that names the file when recording starts. | Offset | Type | Name | Description | |---|---|---|---| | 2 | TEXT | path | Path template, ASCII, no ending `0x00`. 1 to 44 characters (29 on SSR1 hardware) | The syntax is under *Path Templates* in the *SSR Shell Reference*. The query reply carries the template as TEXT. More NACKs: - 12 `NACK_PATH_LEN` – the template is too long - 13 `NACK_PATH_SYNTAX` – a syntax error, such as an unclosed bracket, or a `?` - 14 `NACK_PATH_INV_TOKEN` – an unknown field code - 15 `NACK_PATH_SEQ` – a sequence field in a directory name; it is allowed only in the file name - 16 `NACK_PATH_XLEN` – the path is too long once its fields are filled in (80 characters, 64 on SSR1 hardware) Set the path template of channel 1 to `log/[ymd]/c1[hms].dat`: ```text Host: 81 A1 50 17 33 01 6C 6F 67 2F 5B 79 6D 64 5D 2F 63 31 5B 68 6D 73 5D 2E 64 61 74 38 B7 Logger: 81 A1 90 01 50 E1 02 ``` ### File Size (0x34) The size or time at which a recording is closed and a new file opened. | Offset | Type | Name | Description | |---|---|---|---| | 2 | U1 | size | Bits 3–0, see the table. Bits 7–4 are ignored. | Table: File Size Values | Value | New file | Value | New file | |:---:|---|:---:|---| | 0 | off (one file) | 8 | every 128 MB | | 1 | every 1 MB | 9 | every 256 MB | | 2 | every 2 MB | 10 | every 512 MB | | 3 | every 4 MB | 11 | every 1024 MB | | 4 | every 8 MB | 12 | every hour | | 5 | every 16 MB | 13 | every day | | 6 | every 32 MB | 14 | every week | | 7 | every 64 MB | 15 | off (stored as 0) | ## Global Items A global item applies to the whole logger. Table: Global Item Layouts | Message | Payload | |---|---| | Set request (`0x50`) | U1 CID, U1 value | | Query request (`0x51`) | U1 CID | | Query reply (`0x51`) | U1 CID, U1 value | Errors common to global items: 1 `NACK_INV_LEN`, 33 `NACK_BAD_PARAM` (value out of range). Set the status outputs to *react*, then read the setting back: ```text Host: 81 A1 50 02 40 01 93 C7 Logger: 81 A1 90 01 50 E1 02 Host: 81 A1 51 01 40 92 35 Logger: 81 A1 51 02 40 01 94 CB ``` ### Status Outputs (0x40) What the status outputs S1 to S3 show, as the shell `config outputs`. | Offset | Type | Name | Description | |---|---|---|---| | 1 | U1 | mode | 0 record: high while the channel records (factory setting)
1 react: recording and activity, for indicator LEDs | ### TL Timestamps (0x41) The time stamp written before each line of a tagged line (`tl`) file, on every channel, as the shell `config tlformat`. A file keeps the format it was opened with; a change applies from the next file. | Offset | Type | Name | Description | |---|---|---|---| | 1 | U1 | format | 0 terse: `YYMMDDhhmmss.sss` and a space, 17 bytes (factory setting)
1 iso: `YYYY-MM-DD hh:mm:ss.sss` and a comma, 24 bytes | ### LEDs (0x42) | Offset | Type | Name | Description | |---|---|---|---| | 1 | U1 | operation | 0 on (factory setting), 1 off, 2 on for 10 s after power-up, then off | ### Pin 19 (0x43) The function of pin 19 of the main connector, as the shell `config p19`. | Offset | Type | Name | Description | |---|---|---|---| | 1 | U1 | function | 0 none (factory setting)
1 leds: low enables the LEDs, overriding an [LEDs](#leds-0x42) setting of off or of on for 10 s
2 shell: low requests the shell on the RecShell channel | More NACKs: 36 `NACK_P19_NEEDED` – pin 19 cannot be moved off *shell* while a RecShell channel depends on it. ### USB Enable (0x44) SSR-1U and SSR-SDU. When the card is handed to the USB connection, as the shell `config usben`. While USB has the card, recording stops on every channel. | Offset | Type | Name | Description | |---|---|---|---| | 1 | U1 | condition | 0 lo: while the USB enable input is low
1 hi: while it is high (factory setting)
2 off: never
3 on: always | ### Control (0x45) Whether the shell channel also accepts control protocol packets, as the shell `config control` ([Enabling the Control Channel](#enabling-the-control-channel)). A channel set to `control` accepts packets whatever this item is. Set to 0 from the shell channel, the ACK is the last packet the logger answers there; the shell's `config control on` turns packets back on. | Offset | Type | Name | Description | |---|---|---|---| | 1 | U1 | on | 0: the shell only
1: the shell and control protocol packets (factory setting) | # File Access File access reads, writes, lists, renames, and deletes files on the logger's card. It is available on SSR1L, SSR1U, and SSRSDU hardware; [File Access Information (0x27)](#file-access-information-0x27) tells a host whether a logger has it. Recording continues during file access. ## What a Host Can Do Table: File Access Tasks | Task | Messages | |---|---| | Check that file access is available, and the data sizes | File Access Information (`0x27`) | | List a directory | Directory First (`0x64`), then Directory Next (`0x65`) until an empty reply | | Download a file, simply | Open File (`0x66`) to read; Read Data (`0x69`) repeatedly; Close File (`0x67`) | | Download a file, fast | Open File (`0x66`) to read; Stream Blocks (`0x6E`); Close File (`0x67`); Stop Stream (`0x6F`) to stop early | | Write a file | Open File (`0x66`) to create; Write Data (`0x68`) repeatedly; Close File (`0x67`) | | Rename or move a file or directory | Rename (`0x6D`) | | Delete a file or an empty directory | Delete (`0x62`) | | Make a directory | Make Directory (`0x61`) | | Change or show the current directory | Change Directory (`0x60`), Current Directory (`0x63`) | | Random access in the open file | Seek (`0x6B`), Position (`0x6C`), Sync File (`0x6A`) | ## File Access Rules ### Paths - The separator is `/`. A path that starts with `/` is absolute; any other path is relative to the current directory, which is `/` after a reset. A path may end with `/`. - Hosts SHOULD use absolute paths: they do not depend on what an earlier exchange left behind. - `.` and `..` are understood. - Names are not case sensitive and keep the case they were written with (FAT and exFAT). Long names are supported. - The longest path, including its ending `0x00`, is the *max path* of File Access Information: 126 bytes, 125 characters. A longer path is refused with `NACK_INVALID_PATH`. ### One Open File The logger keeps one file open for the host at a time. Open File closes a file that is already open. Read Data, Write Data, Seek, Position, Sync File, and Stream Blocks act on the open file. Close it with Close File when done: written data is safe on the card only after Close File or Sync File. ### Data Sizes File data moves in pieces whose largest sizes are given by File Access Information. Current models give 1024 bytes for both. - **Read size:** the most data in one Read Data reply, and the block size of Stream Blocks: block k starts at byte k × read size. - **Write size:** the most data in one Write Data request. A host MUST use the sizes the logger reports, not assume 1024. ### Listing Directory First and Directory Next return one entry per reply. `.` and `..` are not listed. Entries come in their order on the card, not sorted. A listing ends with a reply with an empty payload. One listing can be in progress at a time: Directory First starts a new one. ### Dates and Times Entry dates and times use the FAT encoding in the logger's local clock time: Table: FAT Date and Time | Field | Bits | Meaning | |---|---|---| | Date U2 | 15–9 | Year − 1980 | | | 8–5 | Month, 1–12 | | | 4–0 | Day, 1–31 | | Time U2 | 15–11 | Hour, 0–23 | | | 10–5 | Minute, 0–59 | | | 4–0 | Second ÷ 2, 0–29 | ### Files Being Recorded A file that a recording channel has open is *being recorded*. Table: Files Being Recorded | Operation | On a file being recorded | |---|---| | Listing | Listed, with attribute bit 7 (`0x80`) set | | Open to read, Read Data, Stream Blocks | Allowed. The host reads the file as it was at its last sync (each recording is synced about every 3 s); the file's size is fixed when it is opened, so data recorded after that is not seen. | | Open to write, create, or append; Delete; Rename | Refused: 30 `NACK_FILE_LOCKED` | To follow a file as it is recorded, as the shell's `tail -f` does, check its size from time to time (Directory First), and when it has grown, close the file, open it again, Seek to where the last read ended, and read on. `tail -f` does the same: every 500 ms it reads the size from the directory and reopens the file. A file the host itself has open for writing cannot be deleted or renamed until it is closed. ## Change Directory (0x60) Request: STR path of an existing directory. Reply: ACK. Sets the current directory, used by relative paths and Current Directory. NACKs: 27 `NACK_PATH_NOT_FOUND`, 28 `NACK_INVALID_PATH`, 1 `NACK_INV_LEN`. ## Make Directory (0x61) Request: STR path. Reply: ACK. The parent directory must exist. NACKs: 29 `NACK_ACCESS_DENIED` (it exists already), 27 `NACK_PATH_NOT_FOUND`, 28 `NACK_INVALID_PATH`. ## Delete (0x62) Request: STR path of a file or an empty directory. Reply: ACK. NACKs: 26 `NACK_FILE_NOT_FOUND`, 27 `NACK_PATH_NOT_FOUND`, 29 `NACK_ACCESS_DENIED` (directory not empty, or read-only), 30 `NACK_FILE_LOCKED` (being recorded, or open for writing by the host). Deleting a file that is being recorded: ```text Host: 81 A1 62 14 2F 6C 6F 67 73 2F 63 32 5F 31 34 34 31 30 30 2E 64 61 74 00 0E 2E Logger: 81 A1 91 02 62 1E 13 2C ``` The request names `/logs/c2_144100.dat`; the reply is NACK of `0x62`, code 30. ## Current Directory (0x63) Request: no payload. Reply `0x63`: STR absolute path of the current directory. ## Directory First (0x64) and Directory Next (0x65) Directory First request: STR path of a directory, or no payload for the current directory. Directory Next request: no payload. Reply, ID `0x64` or `0x65`: one entry, or an empty payload when there are no more. Table: Directory Entry | Offset | Type | Name | Description | |---|---|---|---| | 0 | U8 | size | File size in bytes (0 for a directory) | | 8 | U2 | date | Last written, date ([Dates and Times](#dates-and-times)) | | 10 | U2 | time | Last written, time | | 12 | U1 | attributes | Bit 0 read-only, bit 1 hidden, bit 2 system, bit 4 directory, bit 5 archive, bit 7 being recorded; bits 3 and 6 are 0 | | 13 | STR | name | The name, not the full path | NACKs to Directory First: 27 `NACK_PATH_NOT_FOUND`, 28 `NACK_INVALID_PATH`. Directory Next with no listing in progress: 31 `NACK_FILE_INVALID`. Listing `/logs`: a file of 74,565 bytes written 2026-10-25 14:30:10, a file being recorded, and the end of the listing: ```text Host: 81 A1 64 06 2F 6C 6F 67 73 00 4E 57 Logger: 81 A1 64 1B 00 00 00 00 00 01 23 45 5D 59 73 C5 20 63 32 5F 31 34 33 30 31 30 2E 64 61 74 00 7A 6B Host: 81 A1 65 00 65 CA Logger: 81 A1 65 1B 00 00 00 00 00 14 00 00 5D 59 75 20 A0 63 32 5F 31 34 34 31 30 30 2E 64 61 74 00 04 43 Host: 81 A1 65 00 65 CA Logger: 81 A1 65 00 65 CA ``` The second entry has attributes `0xA0`: archive, and being recorded. ## Open File (0x66) Request: U1 mode, STR path. Reply: ACK. A file already open is closed first. Table: Open Modes | Mode bit | Name | Meaning | |---|---|---| | 0 (`0x01`) | READ | Read access | | 1 (`0x02`) | WRITE | Write access | | 2 (`0x04`) | CREATE | Create the file; fail if it exists, unless FORCE | | 3 (`0x08`) | FORCE | With CREATE: replace an existing file. Without CREATE: create the file if it does not exist | | 4 (`0x10`) | APPEND | Start at the end of the file; create it if it does not exist | Table: Common Open Modes | Mode | Use | |---|---| | `0x01` | Read an existing file | | `0x06` | Write a new file; fail if it exists | | `0x0E` | Write a file, replacing any existing one | | `0x12` | Add to the end of a file, creating it if needed | | `0x03` | Read and write an existing file from the start | NACKs: 26 `NACK_FILE_NOT_FOUND`, 27 `NACK_PATH_NOT_FOUND`, 29 `NACK_ACCESS_DENIED` (exists, and CREATE without FORCE; a read-only file opened to write; a directory), 30 `NACK_FILE_LOCKED` (WRITE, CREATE, or APPEND on a file being recorded), 28 `NACK_INVALID_PATH`, 1 `NACK_INV_LEN`. Open `/logs/c2_143010.dat` to read: ```text Host: 81 A1 66 15 01 2F 6C 6F 67 73 2F 63 32 5F 31 34 33 30 31 30 2E 64 61 74 00 13 21 Logger: 81 A1 90 01 66 F7 18 ``` ## Close File (0x67) Request: no payload. Reply: ACK. Writes any buffered data and closes the open file. NACKs: 31 `NACK_FILE_INVALID` (no file open). ## Write Data (0x68) Request: U2 n, DATA[n], with 1 ≤ n ≤ write size. Reply: ACK when all n bytes are written at the file position; the position moves on by n. NACKs: 31 `NACK_FILE_INVALID` (no file open), 29 `NACK_ACCESS_DENIED` (not opened for writing), 33 `NACK_BAD_PARAM` (n is 0, more than the write size, or more than the data in the packet), 35 `NACK_DISK_FULL` (the card is full: fewer than n bytes were written). Write the 12 bytes `setpoint=42\n`: ```text Host: 81 A1 68 0E 00 0C 73 65 74 70 6F 69 6E 74 3D 34 32 0A A5 4E Logger: 81 A1 90 01 68 F9 1A ``` ## Read Data (0x69) Request: U2 n, with 1 ≤ n ≤ read size. Reply `0x69`: U2 got, DATA[got]. got is n, except at the end of the file: less than n for the last part, and 0 when the position is already at the end. The position moves on by got. NACKs: 31 `NACK_FILE_INVALID` (no file open), 29 `NACK_ACCESS_DENIED` (not opened for reading), 33 `NACK_BAD_PARAM`. Ask for up to 1024 bytes and get the last 5 bytes of the file, `12.5\n`: ```text Host: 81 A1 69 02 04 00 6F B2 Logger: 81 A1 69 07 00 05 31 32 2E 35 0A 45 C2 ``` ## Sync File (0x6A) Request: no payload. Reply: ACK. Writes the open file's buffered data and size to the card without closing it. ## Seek (0x6B) Request: U8 offset from the start of the file. Reply: ACK. A file open for reading cannot be positioned past its end: 32 `NACK_FILE_SEEK_FAIL`. A file open for writing is extended to the offset. Seek to byte 73728: ```text Host: 81 A1 6B 08 00 00 00 00 00 01 20 00 94 B9 Logger: 81 A1 90 01 6B FC 1D ``` ## Position (0x6C) Request: no payload. Reply `0x6C`: U8 current position. 31 `NACK_FILE_INVALID` if no file is open. ## Rename (0x6D) Request: STR from, STR to. Reply: ACK. Renames a file or directory; it may move to another directory. NACKs: 26 `NACK_FILE_NOT_FOUND` (from), 27 `NACK_PATH_NOT_FOUND`, 29 `NACK_ACCESS_DENIED` (to exists already), 30 `NACK_FILE_LOCKED` (from is being recorded, or open for writing by the host), 28 `NACK_INVALID_PATH`, 1 `NACK_INV_LEN`. Rename `/notes/cfg.txt` to `/notes/cfg_old.txt`: ```text Host: 81 A1 6D 22 2F 6E 6F 74 65 73 2F 63 66 67 2E 74 78 74 00 2F 6E 6F 74 65 73 2F 63 66 67 5F 6F 6C 64 2E 74 78 74 00 B7 5C Logger: 81 A1 90 01 6D FE 1F ``` ## Stream Blocks (0x6E) and Stop Stream (0x6F) Stream Blocks sends a run of blocks of the open file without a request for each block, so a download runs at nearly the full line rate. It is optional: Read Data does the same job one block per exchange. #### Request The file must be open for reading. | Offset | Type | Name | Description | |---|---|---|---| | 0 | U4 | first | First block to send; block k starts at byte k × read size | | 4 | U2 | count | Number of blocks; 0 = to the end of the file | #### Block packets The logger then sends one packet with ID `0x6E` per block, in order: | Offset | Type | Name | Description | |---|---|---|---| | 0 | U4 | block | Block number | | 4 | U2 | n | Data bytes in this block | | 6 | DATA[n] | data | The block's data | The stream ends after *count* blocks, or after a block with n less than the read size (the end of the file), whichever comes first. If the file ends exactly at a block boundary, the last packet has n = 0. If *first* is at or past the end of the file, the only packet is block *first* with n = 0. With a read size of 1024, a full block packet is 1038 bytes: a 1030-byte payload padded to 1032 (Count `0xF1`). If an error stops the stream, for example the card is removed, the logger sends NACK [`0x6E`, code] in place of the next block, and the stream ends. A NACK before any block (no file open, or not open for reading) ends it the same way. After a stream, the file position is the end of the last block sent. #### Stopping a stream Stop Stream (`0x6F`, no payload) asks the logger to stop. It finishes the packet it is sending, sends no more blocks, and replies ACK [`0x6F`]. Block packets already on their way can arrive before that ACK: the host discards block packets until it sees it. Stop Stream when no stream is running is also answered ACK, so a host can always use it to return to a known state. While a stream runs, the host MUST NOT send anything except Stop Stream. #### Errors and resuming The host checks each block packet: its checksum, and that its block number is the one expected next. If a packet is missing or damaged: 1. Send Stop Stream, and discard packets until its ACK. 2. Send Stream Blocks again, with *first* = the first block not received correctly. Each block's number and position are fixed, so a download can be resumed this way after any interruption, as long as the file is open (or opened again). #### Flow control There is none beyond the serial line: the logger sends as fast as the baud rate allows. A host that cannot keep up for a whole file, such as a small microcontroller, SHOULD ask for a few blocks at a time (count 1 to 4) and send the next Stream Blocks when they have been handled. #### Example Download a 74,565-byte file: 72 full blocks and one of 837 bytes. ```text Host: 81 A1 66 15 01 2F 6C 6F 67 73 2F 63 32 5F 31 34 33 30 31 30 2E 64 61 74 00 13 21 Logger: 81 A1 90 01 66 F7 18 Host: 81 A1 6E 06 00 00 00 00 00 00 74 9A Logger: 81 A1 6E F1 00 00 00 00 04 00 <1024 data bytes> 00 00 Logger: 81 A1 6E F1 00 00 00 01 04 00 <1024 data bytes> 00 00 ... Logger: 81 A1 6E DA 00 00 00 48 03 45 <837 data bytes> 00 00 00 00 00 Host: 81 A1 67 00 67 CE Logger: 81 A1 90 01 67 F8 19 ``` Open to read; stream from block 0 to the end; blocks 0 to 71 have n = 1024; block 72 has n = 837, the end of the file; close. ## File Access Sequences Each line is one request and its reply. **Check for file access** ```text 0x27 -> 0x27 version 1, flags 0x03, read 1024, write 1024, max path 126 ``` **List /logs** ```text 0x64 "/logs" -> 0x64 entry 0x65 -> 0x65 entry (repeat) 0x65 -> 0x65 empty (done) ``` **Download, simple (any host)** ```text 0x66 01 "/logs/c2_143010.dat" -> ACK 0x69 1024 -> 0x69 got 1024, data (repeat while got = 1024) 0x69 1024 -> 0x69 got 837, data (got < 1024: done) 0x67 -> ACK ``` **Write a small file from an embedded host** ```text 0x66 0E "/notes/cfg.txt" -> ACK (create or replace) 0x68 12 "setpoint=42\n" -> ACK (repeat for more data) 0x67 -> ACK (now safe on the card) ``` **Replace a file safely** ```text 0x66 06 "/notes/cfg.new" -> ACK 0x68 ... -> ACK 0x67 -> ACK 0x62 "/notes/cfg.txt" -> ACK 0x6D "/notes/cfg.new" "/notes/cfg.txt" -> ACK ``` ## File Access Conformance A host SHOULD be checked against these cases. The logger side is checked by the Slerj test suite. Table: File Access Conformance Cases | # | Case | Expected | |---|---|---| | 1 | File Access Information | Version 1, flags `0x03`, read and write size 1024 | | 2 | List a directory with entries longer than 127 bytes (long names) | Names end at `0x00`; padding ignored | | 3 | Read a file whose size is not a multiple of 1024 with Read Data | Last reply got < 1024; then got = 0 | | 4 | Stream a whole file; compare with a Read Data download | Identical; last block n < 1024, or n = 0 | | 5 | Stream count 3 from block 5 | Blocks 5, 6, 7 only | | 6 | Stop Stream part way, then resume from the next block | ACK [`0x6F`]; resumed data identical | | 7 | Stop Stream with no stream running | ACK | | 8 | Stream with *first* past the end | One packet, n = 0 | | 9 | Write a 3000-byte file in 1024-byte pieces, close, read back | Identical | | 10 | Write Data with n = 0, and n = write size + 1 | `NACK_BAD_PARAM` | | 11 | Open a file being recorded, to read | ACK; the listing shows attribute bit 7 | | 12 | Open it to write; Delete it; Rename it | `NACK_FILE_LOCKED` | | 13 | Rename across directories; rename onto an existing name | ACK; `NACK_ACCESS_DENIED` | | 14 | Change Directory, then a relative path; Current Directory | The relative path is resolved there; Current Directory returns it | | 15 | A request with a bad checksum | No reply | ## Host Software Slerj provides PC software (Python with the pyserial package) that uses control protocol file access: - **ssrfile.py** – a Python library for file access: the reference host implementation. - **ssrftp** – an FTP server that runs on the PC and shows the logger's card to any FTP client: FileZilla, Windows File Explorer, or the Windows `ftp` command. A file being recorded is listed read-only and can be downloaded. It is described in *AN003 – Card Access with ssrftp*. # Error Codes The second payload byte of a NACK is one of these codes. Table: Error Codes | Code | Name | Meaning | |---|---|---| | 1 | NACK_INV_LEN | The payload is not the length the message needs. | | 2 | NACK_INV_CH | Invalid channel number. Channels are numbered from 1. | | 3 | NACK_INV_NV | No valid configuration is saved. | | 4 | NACK_INV_DATE | The date is not valid, or not from 2001 to 2099. | | 5 | NACK_INV_TIME | The time is not valid. | | 6 | NACK_INV_BAUD | The baud rate is below 600 or above the logger's maximum. | | 7 | NACK_INV_PARITY | The parity is not valid, or not supported with the data bits. | | 8 | NACK_INV_STOP | The stop bits value is not valid. | | 9 | NACK_SHCTRL_TAKEN | Another channel is already control, shell, or RecShell. | | 10 | NACK_INV_SOURCE | The command source is not valid. | | 11 | NACK_INV_FM | The file mode is not valid. | | 12 | NACK_PATH_LEN | The path template is too long. | | 13 | NACK_PATH_SYNTAX | The path template has a syntax error. | | 14 | NACK_PATH_INV_TOKEN | The path template has an unknown field code. | | 15 | NACK_PATH_SEQ | A sequence field in a directory name; it is allowed only in the file name. | | 16 | NACK_PATH_XLEN | The path is too long once its fields are filled in. | | 17 | NACK_SD_DISK_ERR | The card reported an error. | | 18 | NACK_SD_INT_ERR | Internal file system error. | | 19 | NACK_SD_NOT_READY | No card, or the card is not ready. | | 20 | NACK_SD_INV_DRIVE | Invalid drive (not expected). | | 21 | NACK_SD_NOT_ENABLED | The card is not mounted: ejected, or USB has it. | | 22 | NACK_SD_NO_FS | No FAT or exFAT file system on the card. | | 23 | NACK_SD_TIMEOUT | The card, or a card eject or mount, did not complete in time. | | 24 | NACK_SD_UNKNOWN | Other card or file system error. | | 25 | NACK_UNKNOWN | The message ID or configuration ID is not recognized. | | 26 | NACK_FILE_NOT_FOUND | No such file. | | 27 | NACK_PATH_NOT_FOUND | A directory in the path does not exist. | | 28 | NACK_INVALID_PATH | The path is badly formed, or too long. | | 29 | NACK_ACCESS_DENIED | It exists already, is read-only, the directory is not empty, the open file has the wrong access, or USB has the card. | | 30 | NACK_FILE_LOCKED | The file is being recorded, or is open for writing by the host. | | 31 | NACK_FILE_INVALID | No file open, or no listing in progress. | | 32 | NACK_FILE_SEEK_FAIL | Seek past the end of a file open for reading. | | 33 | NACK_BAD_PARAM | A value is out of range. | | 34 | NACK_NOT_RECORD | Record for a channel whose function is not record or RecShell. | | 35 | NACK_DISK_FULL | The card is full. | | 36 | NACK_P19_NEEDED | RecShell needs pin 19 set to shell. | # Appendix A. Example Session Channel 4 of an SSR-1U is the control channel. The exchange sets channel 1 to record time tagged archives under a dated directory, saves the configuration, sets the clock, starts recording, checks that the file is open, and stops. Table: Example Session | Packet | Meaning | |---|---| | `81 A1 50 03 30 01 01 85 2F` | Set channel 1 file type to time tagged | | `81 A1 90 01 50 E1 02` | ACK | | `81 A1 50 17 33 01 6C 6F 67 2F 5B 79 6D 64 5D 2F 63 31 5B 68 6D 73 5D 2E 64 61 74 38 B7` | Set channel 1 path template to `log/[ymd]/c1[hms].dat` | | `81 A1 90 01 50 E1 02` | ACK | | `81 A1 50 01 02 53 F4` | Save the configuration | | `81 A1 90 01 50 E1 02` | ACK | | `81 A1 30 04 07 EA 0A 14 43 36` | Set the date to 2026-10-20 | | `81 A1 90 01 30 C1 E2` | ACK | | `81 A1 31 03 0E 1E 00 60 67` | Set the time to 14:30:00 | | `81 A1 90 01 31 C2 E3` | ACK | | `81 A1 10 01 01 12 33` | Record on channel 1 | | `81 A1 90 01 10 A1 C2` | ACK | | `81 A1 23 01 01 25 6C` | Channel Status, channel 1 | | `81 A1 23 02 01 93 B9 27` | Channel 1 recording | | `81 A1 11 01 01 13 36` | Stop channel 1 | | `81 A1 90 01 11 A2 C3` | ACK | # Appendix B. Reference Code Portable C99 with no dynamic memory, suitable for Arduino. The host supplies `ser_write`, `ser_read_byte` (returns -1 if nothing arrives within `ms` milliseconds), and `millis`. ```c #include #include #define SSR_MAX_PAYLOAD 1144 extern void ser_write(const uint8_t *b, int n); extern int ser_read_byte(uint32_t ms); extern uint32_t millis(void); /* Build a packet in out[] (at least payload length + 13 bytes); returns its length. */ int ssr_build(uint8_t *out, uint8_t id, const uint8_t *pay, int n) { int padded = n, i; uint8_t count; if (n <= 127) count = (uint8_t)n; else { padded = (n + 7) & ~7; count = (uint8_t)(0x80 | ((padded - 128) >> 3)); } out[0] = 0x81; out[1] = 0xA1; out[2] = id; out[3] = count; if (n) memcpy(out + 4, pay, n); memset(out + 4 + n, 0, padded - n); /* pad with 0x00 */ uint8_t c1 = 0, c2 = 0; for (i = 2; i < 4 + padded; ++i) { c1 += out[i]; c2 += c1; } out[4 + padded] = c1; out[5 + padded] = c2; return padded + 6; } /* Receive one packet. Returns the (padded) payload length, or -1 on timeout. Packets with a bad checksum are skipped. */ int ssr_receive(uint8_t *id, uint8_t *pay, uint32_t timeout_ms) { uint32_t start = millis(); for (;;) { int b, prev = -1, n, i; for (;;) { /* find 81 A1 */ uint32_t left = timeout_ms - (millis() - start); if ((int32_t)left <= 0) return -1; if ((b = ser_read_byte(left)) < 0) return -1; if (prev == 0x81 && b == 0xA1) break; prev = b; } int hid = ser_read_byte(500), hc = (hid < 0) ? -1 : ser_read_byte(500); if (hc < 0) continue; /* gap: start again */ n = (hc & 0x80) ? 128 + (hc & 0x7F) * 8 : hc; uint8_t c1 = (uint8_t)hid, c2 = c1; c1 += (uint8_t)hc; c2 += c1; for (i = 0; i < n; ++i) { if ((b = ser_read_byte(500)) < 0) break; pay[i] = (uint8_t)b; c1 += (uint8_t)b; c2 += c1; } if (i < n) continue; int k1 = ser_read_byte(500), k2 = (k1 < 0) ? -1 : ser_read_byte(500); if (k2 < 0 || k1 != c1 || k2 != c2) continue; /* bad: discard */ *id = (uint8_t)hid; return n; } } /* Example: Read Data. bytes_requested <= the read size from 0x27. Returns the bytes read (fewer at the end of the file, 0 there), or -1 on error. */ int ssr_read(uint8_t *dst, uint16_t bytes_requested) { uint8_t pkt[16], id, pay[SSR_MAX_PAYLOAD]; uint8_t req[2] = { (uint8_t)(bytes_requested >> 8), (uint8_t)bytes_requested }; ser_write(pkt, ssr_build(pkt, 0x69, req, 2)); int n = ssr_receive(&id, pay, 1000); if (n < 2 || id != 0x69) return -1; /* timeout or NACK (0x91) */ int got = (pay[0] << 8) | pay[1]; memcpy(dst, pay + 2, got); return got; } ``` # Appendix C. Changes From Earlier Firmware The control protocol was last described in the 2019 user's manuals (firmware 2.1). A host written for that firmware works with firmware 3.0, with these differences. Table: Changes Since the 2019 Manuals | Message | Change | |---|---| | Date (`0x30`) | The poll reply is 7 bytes: day of year is a U2 at offset 4 and the weekday is at offset 6. The 2019 manuals showed 6 bytes with a one-byte day of year. | | All Channel Status (`0x24`) | The active function uses bits 6–4 and can be 4, RecShell. File state 9: USB has the card. Bit 7 is also set while a channel is commanded to record but cannot, for example with no card. | | Record (`0x10`) | A channel whose function is not record or RecShell is answered NACK 34. Earlier firmware acknowledged it and recorded nothing. | | Function (CID `0x20`) | Value 4 selects RecShell. A value above 4: NACK 33. RecShell with nothing to request the shell: NACK 36. | | File Type (CID `0x30`) | A value of 3 is answered NACK 33 instead of being stored. | | New messages | Card Eject and Mount (`0x12`, `0x13`), Channel Status (`0x23`), RTC Battery (`0x25`), Firmware Version (`0x26`), File Access Information (`0x27`), Unit Identity (`0x28`), and file access (`0x60`–`0x6F`). | | New configuration items | Echo (`0x15`), Status Outputs (`0x40`), TL Timestamps (`0x41`), LEDs (`0x42`), Pin 19 (`0x43`), USB Enable (`0x44`), Control (`0x45`); Query of `0x01`: stored configuration valid. Every shell setting is now available from the control protocol. | | New error codes | 35 `NACK_DISK_FULL`, 36 `NACK_P19_NEEDED`. Codes 26–32 are used by file access. | | Long replies | Replies longer than 127 bytes are padded with `0x00`. | | All messages | A packet that stops part way is discarded after 100 ms without a new byte. | | Shell channel | Accepts control protocol packets as well as typed commands (Control, CID `0x45`; on as shipped). |