/* voltlogger_analyzer Copyright (C) 2015 Dmitry Yu Okunev 0x8E30679C This program 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. This program 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 this program. If not, see . */ #define _GNU_SOURCE #include "configuration.h" #include "macros.h" #include /* getline() */ #include /* atof() */ #include /* getopt() */ #include #include #include "error.h" #include "binary.h" #include "analyzer.h" int main(int argc, char *argv[]) { char realtime = 0; FILE *i_f = stdin, *o_f = stdout; int channelsNum = 1; // Initializing output subsystem { int output_method = OM_STDERR; int output_quiet = 0; int output_verbosity = 9; int output_debuglevel = 9; error_init(&output_method, &output_quiet, &output_verbosity, &output_debuglevel); } // Parsing arguments char c; while ((c = getopt (argc, argv, "ri:N:")) != -1) { char *arg; arg = optarg; switch (c) { case 'r': realtime = 1; break; case 'i': assert ((i_f = fopen(arg, "r")) != NULL); break; case 'N': channelsNum = atoi(optarg); break; default: abort (); } } history_item_t history_item; static uint64_t unixTSNano_prev; while (!feof(i_f)) { while(1) { long pos = ftell(i_f); history_item.row.unixTSNano = get_uint64(i_f, realtime); if (unixTSNano_prev != 0 && llabs((int64_t)history_item.row.unixTSNano - (int64_t)unixTSNano_prev) > 1E9*1E8) { fprintf(stderr, "Wrong unixTSNano\n"); if (i_f != stdin) fseek(i_f, pos+1, SEEK_SET); continue; } unixTSNano_prev = history_item.row.unixTSNano; break; } history_item.row.sensorTS = get_uint64(i_f, realtime); { int i = 0; while (i < channelsNum) history_item.row.value[i++] = get_uint32(i_f, realtime); } fprintf(o_f, "%lu\t%lu", history_item.row.unixTSNano, history_item.row.sensorTS); { int i = 0; while (i < channelsNum) { fprintf(o_f, "\t%u", history_item.row.value[i++]); } } fprintf(o_f, "\n"); } return 0; }