1
0
Files
BasaltMeter/Document/PROTOCOL.md

60 lines
2.1 KiB
Markdown
Raw Normal View History

2025-11-27 14:49:17 +08:00
# Protocol
This document introduce the protocol used between Basalt Presenter and Basalt Trainer.
2026-01-06 19:50:45 +08:00
If there is no specific description, the endian of data is **native endian**, and the alignment also is native.
Because all data are transmitted in local machine, so we use native layout.
2025-11-27 14:49:17 +08:00
## Command Protocol
2026-01-06 16:27:19 +08:00
Before introducing command protocol, it would be better to the priniciple,
that Presenter is the slave application, and Trainer is the master application.
2026-01-06 19:50:45 +08:00
Command protocol is tramsmitted by system named pipe.
The name of pipe is `\\.\pipe\ed0e3f1f-d214-4880-9562-640bce15e72e` on Windows
or `/tmp/ed0e3f1f-d214-4880-9562-640bce15e72e` on POSIX.
2025-11-27 14:49:17 +08:00
|Code|Direction|Comment|
|:---|:---|:---|
2026-01-06 16:27:19 +08:00
|`0x61`|Presenter<--Trainer|Handshake code (Are Presenter ready?)|
|`0x62`|Presenter-->Trainer|Handshake code (Presenter is ready).|
2025-11-27 14:49:17 +08:00
|`0x01`|Presenter-->Trainer|Data was ready. Please Trainer receive it.|
|`0x02`|Presenter<--Trainer|Data has been received. Please go into next loop.|
2026-01-06 16:27:19 +08:00
|`0x71`|Presenter-->Trainer|Actively Stop (Presenter request stop).|
|`0x71`|Presenter<--Trainer|Stop (Trainer agree the stop request, or trainer actively stop).|
2025-11-27 14:49:17 +08:00
### Handshake
2026-01-06 16:27:19 +08:00
At the beginning of execution,
Trainer send handshake code to Presenter first and then Presenter send another handshake code to Trainer back.
After this, both 2 applications start running.
2025-11-27 14:49:17 +08:00
2026-01-06 21:24:47 +08:00
When Trainer send handshake code,
Trainer should attach some values following it to indicate some essential properties of data
which instruct Representer how to generate data.
2026-01-06 16:27:19 +08:00
There is a table introduce these properties:
2025-11-27 14:49:17 +08:00
|Data Type|Comment|
|:---|:---|
|u8|The pixel kind of image|
|u32|The width of image|
|u32|The height of image|
For the all possible values of "pixel kind" in above table, there is also a table:
|Value|Comment|
|:---|:---|
2026-01-06 19:50:45 +08:00
|`0x01`|Grayscale represented by one float32|
|`0x02`|Grayscale represented by one u8|
|`0x03`|RGB represented by three float32|
|`0x04`|RGB represented by three u8|
2025-11-27 14:49:17 +08:00
## Data Protocol
2026-01-06 19:50:45 +08:00
### Pipe
For this kind deliver, it is tramsmitted by system named pipe.
The name of pipe is `\\.\pipe\ebe2a39d-75de-4cf4-933f-c50284149d63` on Windows
or `/tmp/ebe2a39d-75de-4cf4-933f-c50284149d63` on POSIX.