Debian Codegraph @

doc/reveng/radioddity/gd73/protocol.md

raw
1 # GD73 Serial Protocol
2
3 ## General Request/Response Frame Format
4 ```
5 0 1 2 3 4 5 6 7 8 n-2 n-1 bytes
6 +---+---+---+---+---+---+---+---+---+...+---+---+
7 00 |68h|FLG|CMD|SUB| CRC? | Size | Payload |10h|
8 +---+---+---+---+---+---+---+---+---+...+---+---+
9 ```
10
11 | Bytes | Value | Description |
12 |:-------|:------|:------------|
13 | 0 | 68 | Start of frame byte. Fixed. |
14 | 1 | 0f | Flags? Fixed. |
15 | 2:3 | 01 04 | First command send on read. Probably *enter prog mode*. No payload. |
16 | | 00 02 | Response to *enter prog mode* |
17 | | 01 02 | Start read. |
18 | | 00 00 | Read response, contains sequence number and 35h bytes codeplug data. |
19 | | 04 01 | Read ACK, triggers read of next segment. |
20 | | 01 00 | Write request, usually 55bytes payload. |
21 | | 00 01 | Write ACK. |
22 | 4:5 | | CRC |
23 | 6:7 | | The payload size in little endian. |
24 | 8:(n-2)| | The request/response payload. |
25 | n-1 | 10 | The end-of-frame byte. |
26
27
28 ### CRC
29 The CRC is computed over the entire packet, including start and end bytes. For the computation,
30 the packet is interpreted as a sequence of little-endian unsigned 16-bit integer. If the packet
31 does not align with 16bits, it gets 0-padded to a multiple of 16bit.
32
33 Let `v[i]` the i-th of `N` unsigned 16bit integer formed by the 0-padded packet, the CRC is then
34 computed as
35 ```
36 uint32_t crc = 0xffff;
37 for (int i=0; i<N; i++) {
38 if (crc < v[i])
39 crc += 0xffff;
40 crc -= v[i];
41 }
42 ```
43 To check the CRC, the resulting value of `crc` must be 0, to compute the CRC, just set the CRC field
44 to 0, compute the CRC over the entire packet and then set the field within the packet to the value
45 of the result.
46
47
48 ## Enter program mode request (0104h)
49 The request is send before reading and writing the codeplug. The radio responses with 21h bytes in a
50 0002h response. The content/format of the response is unknown
51
52 ## Start read request (0102h)
53 This request initializes the codeplug read process. The radio responds with the first (seq. number
54 0000h) 35h byte-segment of the codeplug. To receive further segments, the host must ACK the received
55 segment with a read-ACK request containing the number of the received segment.
56 ```
57 Host Device
58 | --- Read request (no payload) ---> |
59 | <----- Response 0000 + Data ------- |
60 | --------- ACK seq. 0000 ----------> |
61 | <----- Response 0001 + Data ------- |
62 | --------- ACK seq. 0001 ----------> |
63 ... ...
64 | <----- Response 0a42 + Data ------- |
65 | --------- ACK seq. 0a42 ----------> |
66 | <----- Response 0a43 + Data ------- |
67 ```
68
69 ## Write request (0100h)
70 The write request sends a sequence number and codeplug segment to the device. The device then ACKs
71 the written segment.
72
73