1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//! This crate provides a link for remote server or [`AUTD3 Simulator`].
//!
//! [`AUTD3 Simulator`]: https://github.com/shinolab/autd3-server
pub use ;
pub use AsyncRemote;
pub use RemoteServer;
// # Protocol Specification
//
// ## Message Types
//
// - `0x01`: Configure Geometry
// - `0x02`: Update Geometry
// - `0x03`: Send Data
// - `0x04`: Read Data
// - `0x05`: Close
// - `0x10`: Hello (handshake)
//
// ## Response Status Codes
//
// - `0x00`: OK
// - `0xFF`: Error
//
// ## Message Formats
//
// ### Hello (Handshake)
// Request:
// - 1 byte: message type (0x10)
// - 2 bytes: protocol version (u16, little-endian)
// - 11 bytes: magic string `AUTD3REMOTE`
//
// Response (Success):
// - 1 byte: status (0x00 = OK)
//
// ### Configure/Update Geometry
// Request:
// - 1 byte: message type (0x01 or 0x02)
// - 4 bytes: number of devices (u32, little-endian)
// - For each device:
// - 12 bytes: position (3x f32, little-endian)
// - 16 bytes: rotation quaternion (w, i, j, k as f32, little-endian)
//
// Response (Success):
// - 1 byte: status (0x00 = OK)
//
// ### Send Data
// Request:
// - 1 byte: message type (0x03)
// - Raw TxMessage data for each device
//
// Response (Success):
// - 1 byte: status (0x00 = OK)
//
// ### Read Data
// Request:
// - 1 byte: message type (0x04)
//
// Response (Success):
// - 1 byte: status (0x00 = OK)
// - Raw RxMessage data for each device
//
// ### Close
// Request:
// - 1 byte: message type (0x05)
//
// Response (Success):
// - 1 byte: status (0x00 = OK)
//
// ### Error Response
// - 1 byte: status (0xFF = Error)
// - 4 bytes: error message length (u32, little-endian)
// - N bytes: error message (UTF-8 string)
pub const MSG_CONFIG_GEOMETRY: u8 = 0x01;
pub const MSG_UPDATE_GEOMETRY: u8 = 0x02;
pub const MSG_SEND_DATA: u8 = 0x03;
pub const MSG_READ_DATA: u8 = 0x04;
pub const MSG_CLOSE: u8 = 0x05;
pub const MSG_HELLO: u8 = 0x10;
pub const MSG_OK: u8 = 0x00;
pub const MSG_ERROR: u8 = 0xFF;
pub const REMOTE_PROTOCOL_VERSION: u16 = 1;
pub const REMOTE_PROTOCOL_MAGIC: & = b"AUTD3REMOTE";