void test_speed(const char *name, int file_speed, int speed) { char filename[64]; snprintf(filename, sizeof(filename), "%s-%03d", name, file_speed); out = fopen(filename, "wt"); if (!out) { printf("Can't write to %s: %m\n", filename); exit(1); } printf("%5s %3d\n", name, file_speed); start_reverse(); for (int i = 0; i < 200; ++i) { send_motors(speed, 0, 0, 0, 0); } stop_reverse(); fclose(out); }
static void handle_reverse(struct trainsrv_state *state, int train_id) { struct internal_train_state *train_state = get_train_state(state, train_id); ASSERT(train_state != NULL); int current_speed = speed_historical_get_current(&train_state->speed_history); start_reverse(train_id, current_speed); }