Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1624 giacomo 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *    Giacomo Guidi      <giacomo@gandalf.sssup.it>
10
 *
11
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
12
 *
13
 * http://www.sssup.it
14
 * http://retis.sssup.it
15
 * http://shark.sssup.it
16
 */
17
 
18
#include <stdio.h>
19
#include <unistd.h>
20
#include <stdlib.h>
21
#include <string.h>
22
 
23
#define READ_BUFFER 2000
24
#define DELTA_BUFFER 100
25
 
26
int main(int argc, char *argv[])
27
{
28
 
29
  char buffer[READ_BUFFER+DELTA_BUFFER];
30
  void *p, *last;
31
  int n,delta,size;
32
 
33
  unsigned long long ev = 0;
34
 
35
  FILE *input_file;
36
 
37
  if (argc < 2) {
38
    printf("%s: Enter the input file name [%s filename]\n",argv[0],argv[0]);
39
    exit(1);
40
  }
41
 
42
  input_file = fopen(argv[1],"rb");
43
 
44
  last = buffer + READ_BUFFER;
45
 
46
  while(!feof(input_file)) {
47
 
48
    //move remaining byte
49
    delta = (unsigned int)(buffer) + READ_BUFFER - (unsigned int)(last);
50
    if (delta > 0) memcpy(buffer,last,delta);    
51
 
52
    n = fread(buffer+delta,1,READ_BUFFER+10,input_file);
53
    fseek(input_file,-(delta+10),SEEK_CUR);
54
 
55
    p = buffer;
56
 
57
    while ((unsigned int)(p) + 16 <= (unsigned int)(buffer + READ_BUFFER) &&
58
           (unsigned int)(p) + 16 <= (unsigned int)(buffer + n + delta)) {
59
 
60
      printf("Sensor = %02x ",(*(unsigned int *)(p) & 0xFF));
61
 
62
      printf("Current = %8d ",*(unsigned int *)(p+4));
63
 
64
      printf("TIME = %8d:%8d\n",*(unsigned int *)(p+8),*(unsigned int *)(p+12));
65
 
66
      size = 16;
67
 
68
      ev++;
69
 
70
      p += 16;
71
 
72
      if ((unsigned int)(p) + 10 > (unsigned int)(buffer + n + delta)) break;
73
 
74
      last = p;
75
 
76
    }
77
 
78
    if ((unsigned int)(p) + 10 > (unsigned int)(buffer + n + delta)) break;
79
 
80
  }
81
 
82
  fclose(input_file);
83
 
84
  return 0;
85
 
86
}
87