/[PAMELA software]/calo/unpacking/readev-orig.c
ViewVC logotype

Contents of /calo/unpacking/readev-orig.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Mon Dec 5 16:23:22 2005 UTC (19 years ago) by mocchiut
Branch: MAIN, unpacking
CVS Tags: start, v1r00, HEAD
Changes since 1.1: +0 -0 lines
File MIME type: text/plain
Imported sources

1 /***************************************************************
2 *
3 * routine read_ev: routine to extract an event information
4 * from file acquired with Pamela acquisition programs
5 *
6 * June 2002
7 *
8 ***************************************************************/
9 /*
10 * include needed system headers
11 */
12 #include <stdio.h> /* include standard i/o library */
13 #include <stdlib.h> /* include standard library */
14 #include <string.h> /* include string library */
15 #include <unistd.h> /* include unix standard library */
16 #include <sys/types.h> /* */
17 #include <sys/stat.h> /* */
18 #include <fcntl.h> /* */
19 #include <errno.h> /* error simbol definitions */
20 #include <time.h> /* system time definitions */
21 #include <math.h> /* math library */
22
23 void readev_(long *evnum, long *systime, long *len, unsigned short *data, int *error, int *fd)
24 {
25 long header;
26 const char *hdr = (char *)&header;
27
28 *error = 0;
29
30 /* search the header */
31
32 *error = read(*fd,&header,sizeof(long)) == sizeof(long) ? 0 : -1;
33 while (!(*error) && (header != 0xaaaaaaaa)) {
34 header >>= 8;
35 *error = read(*fd,hdr+3,sizeof(char)) == sizeof(char) ? 0 : -1;
36 }
37 if (*error) return; /* file read error searching the header: exit */
38
39 /* read the event number */
40
41 *error = read(*fd,evnum,sizeof(long)) == sizeof(long) ? 0 : -1;
42 if (*error) return; /* error reading the event number: exit */
43 printf ("%d \n", evnum);
44 /* read the system time */
45
46 *error = read(*fd,systime,sizeof(long)) == sizeof(long) ? 0 : -1;
47 if (*error) return; /* error reading the system time: exit */
48 printf ("%d \n", systime);
49
50 /* read the event length */
51
52 *error = read(*fd,len,sizeof(long)) == sizeof(long) ? 0 : -1;
53 if (*error) return; /* error reading the event length: exit */
54 printf ("%d \n", len);
55
56 /* read the packet */
57
58 *error = read(*fd,data,sizeof(char)*(*len)) == sizeof(char)*(*len) ? 0 : -1;
59 if (*error) return; /* error reading the event length: exit */
60 swab(data,data,*len);
61 *error = 0;
62 }
63
64
65
66
67
68
69
70
71
72

  ViewVC Help
Powered by ViewVC 1.1.23