void master_move_wait (void) { uint8_t i = 0; _current_state = RF_STATE_M_MOVE_WAIT; while ((i < 50) && !((RF_CMD_ROCK | RF_CMD_PAPER | RF_CMD_SCISSORS) & received_command )) { received_command = listen_command (); //received_command = rf_read_byte (10000); i++; } if (((RF_CMD_ROCK | RF_CMD_PAPER | RF_CMD_SCISSORS) & received_command )) { master_result_send (received_command); } else { go_wait(); } }
void go_wait (void) { recorded_move = no_move; latch_move (sync); _current_state = RF_STATE_WAIT; while ( RF_CMD_REQ != received_command && sync != recorded_move) { received_command = listen_command(); } if (sync == recorded_move) { recorded_move = no_move; master_sync_send(); } else { slave_sync_wait(); } }
int main() { signal(SIGINT, &cleanup); wiringPiSetup(); jandroid.motors = initMotors(); jandroid.servos = initServos(); jandroid.socket = init_socket(); while((jandroid.client_socket = add_client(jandroid.socket)) > 0) { printf("%s\n", "Listening for command"); listen_command(jandroid.motors, jandroid.servos, jandroid.client_socket); } cleanup(0); return 0; }