]> www.fi.muni.cz Git - slotcarman.git/blob - protocol.txt
Sound: joined sound files
[slotcarman.git] / protocol.txt
1 Derived from
2 http://translate.google.com/translate?js=n&prev=_t&hl=cs&ie=UTF-8&layout=2&eotf=1&sl=de&tl=en&u=http%3A%2F%2Fslotbaer.de%2Findex.php%2Fscx-digital%2F63-scx-digital-daten-protokoll&act=url
3
4 Original source
5 http://slotbaer.de/index.php/scx-digital/63-scx-digital-daten-protokoll
6
7 Outline
8 =======
9 The control unit broadcasts data packets across the track.
10 The packets are 9 bytes long, and the structure is the following:
11
12 0x55 packet_type data_byte1..6 crc
13
14 The Ole Seeberg's interface adds 0x05 (05 = O.S. :-) after each packet.
15 This byte can be safely ignored.
16
17 There can be noise on the track, so sometimes the packets are received
18 by a reader with an incorrect checksum. Those should be discarded.
19
20 The bus reader apparently does not report packets which are sent by
21 the cars.
22
23 Packet types
24 ============
25
26 0xAA - bus free time
27 --------------------
28 Format: 0x55 0xAA N1 N2 0xF0 0xF0 0xF0 0xF0 CRC
29
30 Sent twice after the car crosses the finish line. This is a message
31 to the car instructing it to send its ID after the given delay.
32 The delay is the ratio of the N1 and N2 numbers. No need to handle
33 this, it is for cars, not race management.
34
35 N1, N2 - fraction specifiying the bus free time. My Pit box with 020 firmware
36         sends the first packet with 0x0C 0x06, and the second one with
37         0x18 0x06
38
39 Example:
40 55 AA 0C 06 F0 F0 F0 F0 7B
41 55 AA 18 06 F0 F0 F0 F0 93
42
43
44 0xCC - car programming
45 ----------------------
46 Format: 0x55 0xCC CTRL 0xFE 0xFF 0xFF 0xFF 0xFF CRC
47
48 Sent twice when matching the car to the particular controller. 
49
50 CTRL:
51         Bit 7 - always 1
52         Bits 6-3 - always 0
53         Bits 2-0 - number of the controller (starting from 0)
54
55 Example:
56 TBD
57
58
59 0xD0 - reset
60 ------------
61 Format: 0x55 0xD0 0xFF N1 N2 0xAA 0xAA 0xAA CRC
62
63 N1, N2 forms the ratio, probably used as a challenge for car control units
64
65 Example:
66 55 D0 FF 0A 05 AA AA AA AD
67
68
69 0xD3 - standings
70 ----------------
71 Format: 0x55 0xD3 P0-P5 CRC
72
73 Sent after passing the start/finish line for the first time in a race
74 and then every 300 ms.
75
76 P0-P5: one byte for each position, starts with the leader.
77         0xFF means there is no car on this position (for example,
78         when not all cars have passed the start line)
79         Bit 7 - 1 if the car is more than 15 laps behind the leader
80         Bits 6-3 - number of laps behind the leader (0-15, set to 0
81                 when bit 7 is set to 1)
82         Bits 2-0 - vehicle number (0-5)
83
84 Example:
85 55 D3 81 FF FF FF FF FF 2C
86
87
88 0xD4 - lap time
89 ---------------
90 Format: 0x55 0xD4 ID R1 R2 MS T1 T2 CRC
91
92 Sent after passing the finish line and then every 300 ms.
93 Lap count and last lap time of the specified vehicle.
94
95 ID: car number (0-5)
96 R1: Round number - higher byte
97 R2: Round number - lower byte (bit 0 is always zero)
98 MS: miscellaneous
99         Bits 7-4 - always 0
100         Bit 3 - least significant bit of T1
101         Bit 2 - unknown
102         Bit 1 - unknown
103         Bit 0 - least significant bit of R2
104 T1: Lap time - higher byte (bit 0 is always zero)
105 T2: Lap time - lower byte
106
107 So the lap number is 256*R1 + R2 + MS & 0x01, and the time is
108 256*T1 + (MS & 0x08 ? 1 : 0)
109
110 Example:
111 55 D4 01 00 00 01 00 00 59  (round 1 - after crossing the start line)
112 55 D4 01 00 02 08 00 E8 32  (round 2)
113 55 D4 01 00 02 0D 00 B6 3C  (round 3)
114 55 D4 01 00 04 0C 04 98 69  (round 4)
115 Box entry example
116 32.203 55 d4 02 00 06 0d 00 fe 4f 05 # Car 2 round 7 time ff ..
117 32.315 55 d4 02 00 06 01 00 00 a9 05 # Car 2 round 7 time 00
118 34.005 55 d4 02 00 06 09 fe fe 13 05 # Here the back button has been presed
119
120
121
122 0xD5 - race setup
123 -----------------
124 Format: 0x055 0xD5 DI R2-R0 0xFF 0xFF CRC
125
126 Sent when the Start button is pressed for two seconds, i.e. before
127 the start of the race.
128
129 DI - lap counting direction. 0x00 means counting from 0 upwards,
130         0xFF means counting from preset number of laps downwards.
131 R2-R0 - number of laps. Only lower 4 bits are used, so the count
132         can be obtained as 256*R2 + 16*R1 + R0
133
134 Example:
135 55 D5 00 FF FF FF FF FF 83
136 55 D5 FF 00 00 04 FF FF CF
137
138
139 0xD6 - fuel level
140 -----------------
141 Format: 0x55 0xD6 F0-F2 N1 N2 B CRC
142
143 Sent about every 500 ms, current fuel level
144
145 F0-F2 - encodes the fuel level for each car in 4 bits (values 0-8);
146         car 0 is in higher-order bits of F0 (F0 >> 4), car 5
147         is in lower-order bits of F2 (F2 & 0x0F).
148 N1,N2 - fuel consumption ratio (e.g. 0x14 0x50 means 0.25, 0x00 0x50
149         means the race w/o fuel consumption).
150 B - 0xAA, but the source reports that 0xFF has been rarely seen here as well.
151
152 Example:
153 55 D6 88 88 88 00 50 AA 3D
154 55 D6 88 18 88 14 50 AA 7F
155
156 A packet with 0xA fuel level has been seen:
157 55 D6 AA 88 88 14 50 AA 25
158 - this is with cars 0 and 1 active. The meaning of this still has to be
159 determined.
160
161
162 0xD7 - brake setting
163 --------------------
164 Format: 0x55 0xD7 CT BR 0x83 0x93 0xDB 0xFF CRC
165
166 CT - the controller which had the back button pressed (0-5)
167 BR - brake level (0x00 - 0 %, 0x02 - 50 %, 0x04 - 100 %)
168
169 Example:
170 TBD
171
172
173 0xDB - qualification
174 --------------------
175 Format: 0x55 0xDB R2-R0 NR 0xFF 0xFF CRC
176
177 Sent after the start of the qualification.
178
179 R2-R0 - number of laps. Only lower 4 bits are used, so the count
180         can be obtained as 256*R2 + 16*R1 + R0
181 NR - number of cars participating in the qualification
182
183
184 0xDC - end of the race
185 ----------------------
186 Format: 0x55 0xDC 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF CRC
187
188 Sent twice when the last vehicle crosses the finish line or the race is stopped.
189
190 Example:
191 55 DC FF FF FF FF FF FF DF
192
193
194 0xDD - race start
195 -----------------
196 Format: 0x55 0xDD 0x00 0xAA 0xAA 0xAA 0xAA 0xAA CRC
197
198 Sent twice after the reset packet (0xD0) has been sent twice.
199
200 Example:
201 55 DD 00 AA AA AA AA AA 42
202
203
204 0xDE - display change
205 ---------------------
206 Format: 0x55 0xDE WE 0xFF 0xFF 0xFF 0xFF 0xFF CRC
207
208 WE - 0 or 1
209
210 Sent in the RES mode: after the SELECT button is pressed for the
211 first time, no packet is sent. The second time the packet with WE = 0
212 is sent, the third time two packets are sent (one weith WE = 0 and
213 one with WE = 1), and the fourth time two packets are sent
214 (one with WE = 1 and one with WE = 0).
215
216 Example:
217 TBD
218
219
220 0xEE - finish line
221 ------------------
222 Format: 0x05 0xEE R0-R5 CRC
223
224 Sent after the car crosses the finish line and sends back its ID.
225
226 R0-R5 - one byte for each car. 0xE7 means that this car has crossed the
227         finish line, every other value means it did not cross it:
228         0xAA is sent for unconnected controllers.
229
230 Example:
231 55 EE F0 E7 F0 AA AA AA 3C
232 55 EE FE FE E7 AA AA AA 1E # Car 2 crosses normal finish line
233 55 EE 02 00 E7 01 00 00 CF # Car 2 drives through pit lane
234 55 EE 82 FF E7 FF FF Ff 90 # Car 2 enters pit lane too fast
235 55 EE F0 F0 E7 AA AA AA B1 # Car 2 enters pit lane
236 55 EE 83 78 E7 14 50 AA 04 # Car 2 enters pit lane too fast?
237
238
239
240 0xFF - controller status
241 ------------------------
242 Format: 0x55 0xFF R0-R5 CRC
243
244 Sent approximately every 102 ms, or when the change is detected.
245
246 R0-R5: For each controller there is one byte.
247         0xAA - set when the controller is not connected
248         otherwise, the bits have the following meaning:
249         Bit 7 - always 1
250         Bit 6 - always 1
251         Bit 5 - lights (0 = on, 1 = off)
252                 (note the lights setting is reported for each controller,
253                 even though the control unit can set it only for all cars
254                 at once)
255         Bit 4 - back button (0 = pressed, 1 = not pressed)
256         Bits 3-0 - throttle (values 0-12 in normal mode, 0-8 in junior mode,
257                 and 0-6 in the pit lane)
258
259 Example:
260 55 FF F0 F0 F0 AA AA AA 7D
261 - controllers 1-3 present and idle, 4-6 not connected
262
263