00001 /*------------------------------------------------------------------------ 00002 *--------------------- WMPSNIFFER -------------------- 00003 *------------------------------------------------------------------------ 00004 * V7.0B 11/05/10 00005 * 00006 * 00007 * File: basic_io.h 00008 * Authors: Danilo Tardioli 00009 * ---------------------------------------------------------------------- 00010 * Copyright (C) 2000-2012, Universidad de Zaragoza, SPAIN 00011 * 00012 * Contact Addresses: Danilo Tardioli dantard@unizar.es 00013 * 00014 * RT-WMP is free software; you can redistribute it and/or modify it 00015 * under the terms of the GNU General Public License as published by the 00016 * Free Software Foundation; either version 2, or (at your option) any 00017 * later version. 00018 * 00019 * RT-WMP is distributed in the hope that it will be useful, but 00020 * WITHOUT ANY WARRANTY; without even the implied warranty of 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00022 * General Public License for more details. 00023 * 00024 * You should have received a copy of the GNU General Public License 00025 * distributed with RT-WMP; see file COPYING. If not, write to the 00026 * Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 00027 * 02111-1307, USA. 00028 * 00029 * As a special exception, if you link this unit with other files to 00030 * produce an executable, this unit does not by itself cause the 00031 * resulting executable to be covered by the GNU General Public License. 00032 * This exception does not however invalidate any other reasons why the 00033 * executable file might be covered by the GNU Public License. 00034 * 00035 *----------------------------------------------------------------------*/ 00036 #ifndef FILE_IO_H_ 00037 #define FILE_IO_H_ 00038 00039 #include <cstdio> 00040 #include "wmp_specific.hh" 00041 00042 #define MAX_FRAME_SIZE 2000 //TODO: WAS 200 00043 00044 struct file_t { 00045 FILE * ptr; 00046 bool open; 00047 char name[256]; 00048 int pos; 00049 }; 00050 00051 typedef struct { 00052 unsigned long long time; 00053 unsigned char num_nodes; 00054 int frame_type; 00055 int len; 00056 double rate; 00057 bool is_wmp; 00058 int time_source; 00059 char data_src; 00060 unsigned int key; 00061 long long t1; 00062 long long t2; 00063 bool t1t2_valid; 00064 unsigned long long onair_local_ts; 00065 bool onair_local_ts_valid; 00066 int simDataLen; 00067 int proto; 00068 int reinserted; 00069 } simData_Hdr; 00070 00071 //typedef struct { 00072 // double x,y,a; 00073 // unsigned char reached; 00074 // unsigned char extra; 00075 // bool pose_is_valid; 00076 //} simData_Node; 00077 00078 00079 00080 00081 00082 void io_init() ; 00083 int io_open_sim_data(char * filename) ; 00084 int io_close_sim_data() ; 00085 int io_get_num_of_nodes() ; 00086 int io_get_file_size() ; 00087 int io_go_to(int n) ; 00088 int io_read_next_sim_data(char * p); 00089 int io_read_sim_data(char * p, int pos) ; 00090 int io_get_sim_data_num_of_elements() ; 00091 int io_reopen_file_to_write(int n_nodes) ; 00092 int io_get_filepos(); 00093 int io_write_sim_frame(char * fdata, int data_size); 00094 int io_get_pose_from_serial(int serial); 00095 int io_change_file(); 00096 int io_change_file(char *p); 00097 00098 void io_flush(); 00099 00100 int io_write_on_tmp_file(char * p, int size); 00101 int io_create_tmp_file(); 00102 int io_close_tmp_file(); 00103 00104 #endif /* FILE_IO_H_ */