This commit is contained in:
Stefan Bühler 2008-07-12 12:12:18 +02:00
parent 054e61e7c8
commit a1e53f0871
4 changed files with 8 additions and 7 deletions

View File

@ -140,6 +140,7 @@ int trial_check_input(trial *t) {
}
int trial_wait_for_input(trial *t) {
if (t->parse_ctx->buffer->len) return trial_check_input(t);
ssize_t len = read(t->socket, buffer, sizeof(buffer));
if (len < 0) {
fprintf(stderr, "read error: %s\n", strerror(errno));

View File

@ -13,7 +13,7 @@
typedef enum { RUN_ERROR, RUN_DONE, RUN_GO_ON, RUN_FINISHED } run_t;
typedef enum { ACCEL, ROLL, BREAK } accel_t;
typedef enum { ACCEL, ROLL, BRAKE } accel_t;
typedef enum { TURN_HARD_LEFT, TURN_LEFT, TURN_STRAIGHT, TURN_RIGHT, TURN_HARD_RIGHT } turn_t;
typedef enum { BOLDER, CRATER, MARTIAN } object_t;
@ -118,7 +118,7 @@ INLINE void vehicle_accel(trial *t) {
switch (t->vehicle.accel) {
case ACCEL: return;
case ROLL: SENDCMD(t, "a;"); break;
case BREAK: SENDCMD(t, "a;a;"); break;
case BRAKE: SENDCMD(t, "a;a;"); break;
}
t->vehicle.accel = ACCEL;
}
@ -126,7 +126,7 @@ INLINE void vehicle_roll(trial *t) {
switch (t->vehicle.accel) {
case ACCEL: SENDCMD(t, "b;"); break;
case ROLL: return;
case BREAK: SENDCMD(t, "a;"); break;
case BRAKE: SENDCMD(t, "a;"); break;
}
t->vehicle.accel = ROLL;
}
@ -134,9 +134,9 @@ INLINE void vehicle_break(trial *t) {
switch (t->vehicle.accel) {
case ACCEL: SENDCMD(t, "b;b;"); break;
case ROLL: SENDCMD(t, "b;"); break;
case BREAK: return;
case BRAKE: return;
}
t->vehicle.accel = BREAK;
t->vehicle.accel = BRAKE;
}
INLINE void vehicle_hard_left(trial *t) {

View File

@ -477,7 +477,7 @@ _match:
break;
case 19:
#line 90 "control_parser.rl"
{ ctx->tm->vehicle.accel = BREAK; }
{ ctx->tm->vehicle.accel = BRAKE; }
break;
case 20:
#line 92 "control_parser.rl"

View File

@ -87,7 +87,7 @@ static timestamp extract_ts(context *ctx, char *fpc) {
ctl = (
"a" @ { ctx->tm->vehicle.accel = ACCEL; }
| "-" @ { ctx->tm->vehicle.accel = ROLL; }
| "b" @ { ctx->tm->vehicle.accel = BREAK; }
| "b" @ { ctx->tm->vehicle.accel = BRAKE; }
) (
"L" @ { ctx->tm->vehicle.turn = TURN_HARD_LEFT; }
| "l" @ { ctx->tm->vehicle.turn = TURN_LEFT; }