@@ -10,30 +10,26 @@ streaming protocol for low-speed embedded applications, such as serial
1010connected devices. It allowes the receiver to 'jump into' a stream of data
1111frames. Every frame starts with a preamble, so the receiver can synchronize.
1212
13- A payload is optional.
14-
1513The format of a frame is as follows:
1614
1715```
16+ | Preamble | Header | Body |
1817| 0xAA 0x55 0xAA 0x55 | AA AA BB BB CC | XX XX .. .. .. .. XX XX YY YY YY YY |
19- | Preamble | Header | Body (optional) |
2018
2119Fields:
22- A = Length
23- B = Flags
20+ A = Flags
21+ B = Length
2422C = XOR checksum over header
25- X = Body payload (max. 65536 bytes)
26- Y = CRC32 checksum over header + body
23+ X = Payload (max. 65536 bytes)
24+ Y = CRC32 checksum over header + payload
2725```
2826
29- The flags field can have arbitrary values, but the following flags are
30- reserved.
27+ The flags field can be used for arbitrary purposes. The payload is optional.
3128
32- * ` 0x01 = RESET `
33- * ` 0x02 = ERROR `
34- * ` 0x04 = PRIORITY `
29+ Escaping of the header and body are performed using byte-stuffing, to ensure
30+ that the header and body can contain bytes of the preamble.
3531
36- Error correction is not implemented and the bytes are not aligned. The
32+ Error correction is not implemented and the bytes are not strictly aligned. The
3733endianness is customizable.
3834
3935## State chart diagram
@@ -45,15 +41,16 @@ The latest development version can be installed via
4541` pip install git+https://github.com/basilfx/python-tinylink ` .
4642
4743## CLI
48- A simple serial CLI is included. When installed, run
44+ A CLI is included to experiment with TinyLink . When installed, run
4945` tinylink /dev/tty.PORT_HERE ` to start it. You can use it to send raw bytes via
5046the link and display what comes back.
5147
5248The CLI supports so-called modifiers to modify the outgoing data. For example,
53- the input ` \flags=1 hello world ` would send a reset frame with the value
54- 'hello world'.
49+ the input ` \flags=16 hello world ` would send a frame with the flags equal to 16
50+ and the payload 'hello world'
5551
56- PySerial is required to run this CLI.
52+ The CLI requires additional dependencies, that are installed using the ` cli `
53+ dependency specification (` poetry install --extras cli ` ).
5754
5855## Tests
5956To run the tests, please clone this repository and run ` poetry run pytest ` .
0 commit comments