/* * sync_master.c * * Copyright (c) 2009 Ismael Gomez-Miguelez, UPC , * Xavier Reves, UPC * All rights reserved. * * * This file is part of ALOE. * * ALOE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ALOE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ALOE. If not, see . * */ #include #include #include #include "phid.h" #include "itf_utils.h" #include "phal_hw_api.h" #include "sync.h" #define ever (;;) #define TEST /*#define NO_URGENT*/ /*#define DEB*/ int sync_run; int testing = 0; char line_str[128]; int fd_w, fd_r; hwitf_t id_w, id_r; int error; #define BUFF_SZ 128 #define MAX_CLIENTS 10 struct client { int fd_w; int fd_r; hwitf_t id_r; hwitf_t id_w; }; void answer_packet(hwitf_t id) { int n1, n2; int error; struct syncdata sd; n1 = hwapi_itf_rcv(fd_r, &sd, sizeof (struct syncdata)); if (!n1) { printf("received 0\n"); return; } get_time(&sd.ref_time); n2 = hwapi_itf_snd(fd_w, &sd, sizeof (struct syncdata)); if (n1