Skip to content

Commit ed8742c

Browse files
committed
Refactored rtxlink specification
1 parent 7b72e4d commit ed8742c

File tree

1 file changed

+66
-88
lines changed

1 file changed

+66
-88
lines changed

rtxlink.md

Lines changed: 66 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,36 @@
11
# RTXLink - OpenRTX Communication Protocol
22

3-
This page describes `rtxlink`: a communication protocol implemented by
4-
OpenRTX and used to accomplish the following functions:
3+
This page describes `rtxlink`, the communication protocol used by the OpenRTX firmware to accomplish the following functions:
54

6-
- Get radio info
7-
- Reboot radio
8-
- Full flash backup/restore
9-
- Download file
10-
- Upload file
11-
- Set RTX params
5+
- Retrieval of radio info
6+
- Reboot of the device
7+
- Backup and restore of the nonvolatile memory
8+
- File download and upload
9+
- Change of some RTX parameters
1210

13-
Additionally, the protocol has the following characteristics:
11+
## Physical Layer
1412

15-
- SLIP is used for framing and encloses the whole protocol
16-
- The protocol is Byte-oriented
17-
- protocol is composed of getters and setters
18-
- variables to get and set are encoded into opcodes
19-
- plain ymodem is used for file transfer
20-
21-
The protocol stack is as follows:
22-
23-
| Application | CAT, FMP, XMODEM |
24-
|:-----------:|:-----------------:|
25-
| Framing | SLIP |
26-
| Physical | UART, VCOM |
27-
28-
## Physical Layer - UART, VCOM
29-
30-
This protocol is designed to be executed on a serial link, which depending on the platform support might be a physical (UART) link or a Virtual COM over USB. Buffering is tolerated by the protocol. The baud rate is 115200.
13+
The physical layer of the rtxlink protocol is a serial communication, which may either be based on a physical link (UART) or a Virtual COM over USB.
14+
In case a physical link is used, its configuration is 8 data bits, no parity and either EIA hardware flow control, or CLOCAL mode (3-wire null-modem).
15+
The default baud rate is 115200 bit per second but the change to a different datarate can be requested by the client device. The support for datarates
16+
other than the default one is not mandatory, although an rtxlink host must support at least 115200 bit per second. The protocol tolerates buffering and
17+
fragmentation of the transmitted data.
3118

3219
## Data Link Layer
3320

34-
The data link layer of RTXLink is composed of frames with a variable length encoded using the SLIP protocol. Each SLIP frame must begin with an END character; incoming frames not beginning with and END character are accepted anyway, even if not strictly conformant to the specification.
35-
36-
### SLIP framing
37-
38-
The framing is performed using the [Serial Line Internet Protocol (SLIP)](https://en.wikipedia.org/wiki/Serial_Line_Internet_Protocol).
39-
The following are the standard value Bytes employed by the SLIP protocol.
40-
41-
| Hex value | Dec Value | Oct Value | Abbreviation | Description |
42-
|:----------|:----------|:------------|:-------------|:------------------------|
43-
| 0xC0 | 192 | 300 | END | Frame End |
44-
| 0xDB | 219 | 333 | ESC | Frame Escape |
45-
| 0xDC | 220 | 334 | ESC_END | Transposed Frame End |
46-
| 0xDD | 221 | 335 | ESC_ESC | Transposed Frame Escape |
47-
48-
SLIP modifies a standard TCP/IP datagram by:
49-
50-
- Appending a special "END" Byte to it, to distinguish datagram boundaries in the Byte stream,
51-
- If the END Byte occurs in the data to be sent, the two Byte sequence ESC, ESC_END is sent instead,
52-
- If the ESC Byte occurs in the data, the two Byte sequence ESC, ESC_ESC is sent.
53-
- Variants of the protocol may begin, as well as end, packets with END.
54-
55-
SLIP requires a serial port configuration of 8 data bits, no parity, and either EIA hardware flow control, or CLOCAL mode (3-wire null-modem) UART operation settings.
56-
57-
SLIP can extend the frame length up to the double of the original length, this needs to be taken into account when sizing buffers during the protocol implementation.
21+
The data link layer of the rtxlink protocol consists of variable-length frames encoded using the [Serial Line Internet Protocol (SLIP)](https://en.wikipedia.org/wiki/Serial_Line_Internet_Protocol).
22+
Each SLIP frame must begin with an END character: incoming frames not beginning with and END character are accepted anyway, even if not strictly conformant to the specification. SLIP can extend
23+
the frame length up to the double of the original length, this needs to be taken into account when sizing buffers during the protocol implementation.
5824

59-
### Frame format
25+
The frames format is the following:
6026

6127
| 0 | 1 | ... | N-1 | N |
6228
|:---:|:-------:|:----:|:----:|:---:|
6329
| END | ProtoID | Data | CRC8 | END |
6430

65-
Following the leading END marker, the first byte of each frame is a protocol identifier describing the frame content, while the last byte of the frame contains the CRC-8 of the protocol ID and data fields. The polynomial used for the CRC is 0xA6, ensuring a minimum hamming distance of 2 for data blocks composed by more than 2048 bytes.
31+
After the star of frame marker, the first byte of each frame is a protocol identifier describing the frame content. The last byte of the frame, following the content and preceding the frame end
32+
marker contains the CRC-8 of the protocol identifier and data fields. The CRC is computed using the polynomial 0xA6 and ensures a minimum hamming distance of two for data blocks composed by more
33+
than 2048 bytes.
6634

6735
The recognized protocol IDs are the following:
6836

@@ -75,61 +43,54 @@ The recognized protocol IDs are the following:
7543

7644
## Application Layer
7745

78-
The application layer is composed of two different protocols: a Computer Aided Transceiver (CAT) protocol to control the operation of the radio and a File Management Protocol (FMP) to request file transfers and memory backup and restore. The actual transfer of files and backup images is performed using the XMODEM protocol.
46+
The application layer of rtxlink consists of two command different protocols: the Computer Aided Transceiver (CAT) protocol and the File Management Protocol (FMP).
7947

8048
### Computer Aided Transceiver (CAT)
8149

82-
Byte encodings are little-endian.
83-
84-
CAT commands are Byte-aligned and encoded in key-value pairs to achieve both simplicity of the protocol and ease of parsing.
85-
86-
The CAT command identifies resources through 2 Byte IDs, and allows the host (main agent of the transmission) to get values associated with each ID or set a new value to a corresponding ID.
87-
88-
The first byte of a CAT command and response packet is the packet OpCode.
50+
The CAT protocol is based on a request/response command structure. Commands are byte-aligned and encoded in key-value pairs to achieve both simplicity of the protocol and ease of parsing. All the
51+
commands and their arguments are encoded in little-endian format. The first byte of each CAT command or response packet is the packet opcode.
8952

9053
#### Get Requests
9154

92-
A get request asks the secondary entity on the RTXLink bus for a value associated with a specific ID. The request is composed by 3 bytes: the first byte is the command OpCode, followed by two symbol identifier bytes.
55+
A get request is used by the rtxlink client to request the value of given entity. The command frame has a fixed length of three bytes, with the opcode set to 0x47 (ASCII character 'D'). Following
56+
the opcode there are two bytes containing the resource ID. In response to a get request the host sends either a data response frame or, in case of failures, an ack frame reporting an error code.
9357

9458
| 0 | 1 | 2 |
9559
|:---:|:--:|:--:|
9660
| CMD | ID | ID |
9761

98-
In response to a get request the radio sends either a data response packet or, in case of failures, an ack packet with the ERROR flag set 1.
99-
10062
#### Set Requests
10163

102-
Set requests allow to change a specific value associated with a certain ID.
103-
Set requests are composed by one command byte, 2 Bytes of symbol ID and N bytes of data.
64+
A set request is used by the rtxlink client to change the value of an entity. The command frame has a variable length with a minimum size of four bytes and the opcode is 0x53 (ASCII character 'S').
65+
Following the opcode there are two bytes containing the resource ID and N bytes of data. In response to a set request the host sends an ack frame with a status code.
10466

10567
| 0 | 1 | 2 | 3 | ... | N |
10668
|:---:|:--:|:--:|:-:|:---:|:-:|
10769
| CMD | ID | ID | V | ... | V |
10870

109-
The radio replies to a set request with an ack response packet with either the OK or ERROR flag set.
110-
11171
#### Peek Requests
11272

113-
Peek requests allow to read the content of a the radio internal memory at a given address. Peek requests are composed by one command byte, one byte of data length and four bytes of address.
73+
A peek request allow the client to read the content of the host internal memory at a given address. The command frame has a fixed length of six bytes, with the opcode set to 0x50 (ASCII character 'P').
74+
After the command opcode, there is one byte of data length and four bytes of address. The host replies to a peek request with a data response packet or, in case of failures, an ack frame reporting an
75+
error code.
11476

11577
| 0 | 1 | 2 | 3 | 4 | 5 |
11678
|:---:|:---:|:----:|:----:|:----:|:----:|
11779
| CMD | LEN | ADDR | ADDR | ADDR | ADDR |
11880

119-
The radio replies to a peek request with a data response packet or, in case of errors, with an ack response packet with the ERROR flag set.
120-
12181
#### Data response
12282

123-
A data response packet starts with a response type byte set to 0x44 (ASCII character 'D') followed by N bytes of data.
83+
A data response frame has the opcode set to 0x44 (ASCII character 'D') followed by N bytes of data. Data response frames are sent in reply to get or peek requests.
12484

12585
| 0 | 1 | ... | N |
12686
|:----:|:-:|:---:|:-:|
12787
| 0x44 | V | ... | V |
12888

12989
#### ACK response
13090

131-
An ack response packet is constituted of two bytes: the first byte (response type) is always set to 0x41 (ASCII character 'A') while the second one carries a status code. A status code equal to zero means that the previous command has been successfully executed. In case of an error the status code field contains a POSIX error code describing the fault or 0xFF to signal a generic, unspecified error.
132-
The absolute minimum requirement is to have the status field set either to 0x00 or 0xFF.
91+
An ack response frame has a fixed length of two bytes: the first byte (opcode) is always set to 0x41 (ASCII character 'A'), the second one carries a status code. A status code zero means that the previous
92+
command has been successfully executed. Othewise, in case an error occurred, the status code field contains a POSIX error code describing the fault or 0xFF to signal a generic, unspecified error. The host
93+
must at least use the values 0x00 and 0xFF for the status field.
13394

13495
| 0 | 1 |
13596
|:----:|:------:|
@@ -140,31 +101,48 @@ The absolute minimum requirement is to have the status field set either to 0x00
140101
| Role | Command | OpCode | Parameters | Length | Description |
141102
|:---------|:--------|:---------|:---------------|:-------- |:------------|
142103
| Request | Get | 0x47 'G' | ID | 3 | Gets the N Byte word corresponding to the specified ID. |
143-
| Response | Data | 0x44 'D' | Value | Variable | The N Byte word which was requested. |
104+
| Response | Data | 0x44 'D' | Value | Variable | The N Byte word which was requested. |
144105
| Request | Set | 0x53 'S' | ID, Value | Variable | Sets a N Byte word to the specified ID. |
145-
| Response | Ack | 0x41 'A' | Status | 1 | Status of the previous Set command, success or error. |
106+
| Response | Ack | 0x41 'A' | Status | 1 | Status of the previous Set command, success or error. |
146107
| Request | Peek | 0x50 'P' | Address | 5 | Gets the 32bit word corresponding to the specified 32-bit address. |
147-
| Response | Data | 0x44 'D' | Value | 5 | The 32bit word which was requested. |
108+
| Response | Data | 0x44 'D' | Value | 5 | The 32bit word which was requested. |
148109

149-
#### Identifiers
110+
#### Get/set resource IDs
150111

151-
OpenRTX CAT uses symbolic values to identify controllable features of the radio, the tables below summarizes the features and the respective sizes, semantics and permissions.
112+
The tables below summarizes the CAT resource identifiers with their respective size, semantic and permissions.
152113

153114
| Permissions | Symbol |
154115
|:---------------|:-------|
155116
| Read Only | R |
156-
| Read and Write | RW |
157-
| Write Only | W |
117+
| Read and Write | RW |
118+
| Write Only | W |
158119

159120
| Symbol | ID | Type (Length) | Permissions | Description |
160-
|:--------------|:------------|:------------|:------------|--------------|
161-
| info | 0x494E 'IN' | String (10) | R | Return radio identifier |
162-
| free_space | 0x4653 'FS' | i32 (4) | R | Return available space in Bytes |
163-
| rx_frequency | 0x5246 'RF' | i32 (4) | RW | Get or set the current VFO receive frequency |
164-
| tx_frequency | 0x5446 'TF' | i32 (4) | RW | Get or set the current VFO transmit frequency |
165-
| power_cycle | 0x5043 'PC' | None | W | Reboot radio |
166-
| file_transfer | 0x4654 'FT' | None | W | Enable File Transfer Mode |
121+
|:--------------|:------------|:--------------|:------------|--------------|
122+
| info | 0x494E 'IN' | String (16) | R | Return radio identifier |
123+
| rx_frequency | 0x5246 'RF' | i32 (4) | RW | Get or set the current VFO receive frequency |
124+
| tx_frequency | 0x5446 'TF' | i32 (4) | RW | Get or set the current VFO transmit frequency |
125+
| baud_rate | 0x4252 'BR' | i32 (4) | W | Set the baud rate of the rtxlink interface |
126+
| power_cycle | 0x5043 'PC' | None | W | Reboot radio |
127+
| file_transfer | 0x4654 'FT' | None | W | Enable File Transfer Mode |
167128

168-
### XMODEM
129+
<!-- | free_space | 0x4653 'FS' | i32 (4) | R | Return available space in Bytes | -->
169130

170-
File transfers are performed through the XMODEM protocol with 16-bit CRC and 1KB blocks.
131+
132+
### Appendix A - SLIP framing
133+
134+
The following are the standard value Bytes employed by the SLIP protocol.
135+
136+
| Hex value | Dec Value | Oct Value | Abbreviation | Description |
137+
|:----------|:----------|:------------|:-------------|:------------------------|
138+
| 0xC0 | 192 | 300 | END | Frame End |
139+
| 0xDB | 219 | 333 | ESC | Frame Escape |
140+
| 0xDC | 220 | 334 | ESC_END | Transposed Frame End |
141+
| 0xDD | 221 | 335 | ESC_ESC | Transposed Frame Escape |
142+
143+
SLIP modifies a standard TCP/IP datagram by:
144+
145+
- Appending a special "END" Byte to it, to distinguish datagram boundaries in the Byte stream,
146+
- If the END Byte occurs in the data to be sent, the two Byte sequence ESC, ESC_END is sent instead,
147+
- If the ESC Byte occurs in the data, the two Byte sequence ESC, ESC_ESC is sent.
148+
- Variants of the protocol may begin, as well as end, packets with END.

0 commit comments

Comments
 (0)