Revision 1271
Added "start_test bom emitter..." and "start_test bom detector"
Bugfix: bom dump reading rangefinder values
comm_server.c | ||
---|---|---|
30 | 30 |
const char command_rangefinder [] PROGMEM = "rangefinder"; |
31 | 31 |
const char command_motor [] PROGMEM = "motor" ; |
32 | 32 |
const char command_encoder [] PROGMEM = "encoder" ; |
33 |
const char command_emitter [] PROGMEM = "emitter" ; |
|
34 |
const char command_detector [] PROGMEM = "detector" ; |
|
33 | 35 |
const char command_help [] PROGMEM = "help" ; |
34 | 36 |
|
35 | 37 |
// Help |
... | ... | |
180 | 182 |
test_comm (); |
181 | 183 |
} |
182 | 184 |
|
185 |
/** If the next parameter is "all", call the test all function. If it's a number, call the test one function. **/ |
|
183 | 186 |
static void handle_message_start_test_component (char *buffer, void (*test_all_fn)(void), void (*test_one_fn)(uint8_t)) |
184 | 187 |
{ |
185 | 188 |
// Find the next parameter |
... | ... | |
202 | 205 |
unhandled_parameters (buffer); |
203 | 206 |
} |
204 | 207 |
|
205 |
static void test_bom_helper (uint8_t num) |
|
206 |
{ |
|
207 |
test_bom (num, true, true); |
|
208 |
} |
|
208 |
static void test_bom_both (uint8_t num) { test_bom (num, true , true ); } |
|
209 |
static void test_bom_emitter (uint8_t num) { test_bom (num, true , false); } |
|
210 |
static void test_bom_detector (uint8_t num) { test_bom (num, false, true ); } |
|
209 | 211 |
|
210 |
static void test_bom_all_helper (void) |
|
211 |
{ |
|
212 |
test_bom_all (true, true); |
|
213 |
} |
|
212 |
static void test_bom_all_both (void) { test_bom_all (true , true ); } |
|
213 |
static void test_bom_all_emitter (void) { test_bom_all (true , false); } |
|
214 |
static void test_bom_all_detector (void) { test_bom_all (false, true ); } |
|
214 | 215 |
|
215 | 216 |
static void handle_message_start_test_bom (char *buffer) |
216 | 217 |
{ |
217 |
// TODO: handle start_test bom _emitter/detector_ all/num |
|
218 |
handle_message_start_test_component (buffer, test_bom_all_helper, test_bom_helper); |
|
218 |
// "start_test bom..." |
|
219 |
char *param=find_next_parameter (buffer); |
|
220 |
|
|
221 |
// In addition to "all" and a number, both handled by handle_message_start_test_component, we can also have |
|
222 |
// "emitter" and "detector" here. Not that we pass param rather than buffer in these cases. |
|
223 |
if (!param) |
|
224 |
// "start_test bom" |
|
225 |
// No paramter found (we could also pass that on to start_test_component) |
|
226 |
parameter_missing (); |
|
227 |
else if (serial_match (command_emitter, param)) |
|
228 |
// "start_test bom emitter..." |
|
229 |
handle_message_start_test_component (param, test_bom_all_emitter, test_bom_emitter); |
|
230 |
else if (serial_match (command_detector, param)) |
|
231 |
// "start_test bom detector..." |
|
232 |
handle_message_start_test_component (param, test_bom_all_detector, test_bom_detector); |
|
233 |
else |
|
234 |
// No emitter/detector given |
|
235 |
handle_message_start_test_component (buffer, test_bom_all_both, test_bom_both); |
|
219 | 236 |
} |
220 | 237 |
|
221 | 238 |
static void handle_message_start_test_rangefinder (char *buffer) |
Also available in: Unified diff