-
Notifications
You must be signed in to change notification settings - Fork 2
/
read_srsdata.cc
108 lines (83 loc) · 2.13 KB
/
read_srsdata.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <fcntl.h>
using namespace std;
main(int argc, char *argv[])
{
if ( argc < 2)
{
cout << "Usage: " << argv[0] << " file" << endl;
exit(1);
}
int fd = open(argv[1], O_RDONLY | O_LARGEFILE );
if (fd < 0)
{
cerr << "could not open " << argv[1] << endl;
exit(1);
}
int nevt = 2;
if ( argc == 3)
{
nevt = atoi (argv[2]);
}
int n;
unsigned int d;
for ( int event = 0; event <nevt; event++)
{
int go_on =1;
while (go_on)
{
n = read( fd, &d, 4);
if ( d == 0xfafafafa ) break;
unsigned int dh = ntohl(d);
// cout << "framecounter: " << (dh & 0xff) << endl;
n = read( fd, &d, 4);
dh = ntohl(d);
//cout << "Header: " << hex << dh << dec << " " ;
unsigned char c = (dh >>24) & 0xff;
//cout << c;
c = (dh >>16) & 0xff;
//cout << c;
c = (dh >>8) & 0xff;
//cout << c;
unsigned int channel = dh & 0xff;
//cout << " channel nr: " << channel << endl;
n = read( fd, &d, 4);
unsigned int header = ntohl(d);
unsigned int words = header & 0xffff;
//cout << " words: " << words << endl;
unsigned short val;
int i = 0;
n = read ( fd, &d, 4);
while ( d != 0xf000f000 && i < words +1)
{
val = ( d & 0xffff);
cout << setw(6) << i++ << setw(6) << val;
if ( val < 1200 ) cout << " D 1";
else if ( val > 3000 ) cout << " D0";
else cout << " ";
cout << endl;
val = ( (d >>16 ) & 0xffff);
cout << setw(6) << i++ << setw(6) << val;
if ( val < 1200 ) cout << " D 1";
else if ( val > 3000 ) cout << " D0";
else cout << " ";
cout << endl;
n = read( fd, &d, 4);
}
}
n = read( fd, &d, 4);
if ( d != 0xf000f000 ) cout << " no EOP marker found " << hex << d << dec << endl;
//cout << " end of event " << event << endl;
}
close (fd);
return 0;
}