1 |
#include <stdio.h> |
#include <stdio.h> |
2 |
#include "ACcalib.h" |
#include "ACcalib.h" |
3 |
|
|
4 |
|
// Program to read AC calibration data |
5 |
|
// 0408 Petter Hofverberg, petter@particle.kth.se |
6 |
|
|
7 |
int ACcalib(int length, unsigned short* datapointer, struct datastruct* calibpointer){ |
int ACcalib(int length, unsigned short* datapointer, struct datastruct* calibpointer) |
8 |
|
{ |
|
struct datastruct calibdata; |
|
|
|
|
|
//pointer to struct |
|
|
struct datastruct *calibpointer; |
|
|
|
|
|
int fd,i,j,err,found; |
|
|
unsigned short buffer[10000]; |
|
|
unsigned short tmp1,tmp2; |
|
|
|
|
|
|
|
9 |
int iter=2; |
int iter=2; |
10 |
|
|
11 |
//point struc-pointer to calibdata |
//point struc-pointer to calibdata |
40 |
else{ |
else{ |
41 |
datapointer++; |
datapointer++; |
42 |
iter=iter+2;} |
iter=iter+2;} |
|
|
|
43 |
} |
} |
44 |
|
|
45 |
//check errors |
//check errors |
54 |
calibdata.header=buffer[0]; |
calibdata.header=buffer[0]; |
55 |
for(i=0;i<5;i++) calibdata.status[i]=buffer[1+i]; |
for(i=0;i<5;i++) calibdata.status[i]=buffer[1+i]; |
56 |
for(i=0;i<8;i++) calibdata.temp[i]=buffer[6+i]; |
for(i=0;i<8;i++) calibdata.temp[i]=buffer[6+i]; |
57 |
for(i=0;i<16;i++) calibdata.DAC[i]=buffer[14+i]; |
for(i=0;i<8;i++) calibdata.DAC1[i]=buffer[14+i]; |
58 |
|
for(i=0;i<8;i++) calibdata.DAC2[i]=buffer[22+i]; |
59 |
for(i=0;i<6;i++) calibdata.regist[i]=buffer[30+i]; |
for(i=0;i<6;i++) calibdata.regist[i]=buffer[30+i]; |
60 |
for(i=0;i<8;i++) calibdata.time[i]=buffer[36+i]; |
for(i=0;i<8;i++) calibdata.time[i]=buffer[36+i]; |
61 |
calibdata.n_tr=buffer[44]; |
calibdata.n_tr=buffer[44]; |
66 |
calibdata.tail=buffer[8254]; |
calibdata.tail=buffer[8254]; |
67 |
calibdata.CRC=buffer[8255]; |
calibdata.CRC=buffer[8255]; |
68 |
|
|
69 |
/* |
/* |
70 |
//debug |
//debug |
71 |
printf("header: %hx\n",calibdata.header); |
printf("header: %hx\n",calibdata.header); |
72 |
printf("status: %hx\n",calibdata.status[0]); |
printf("status: %hx\n",calibdata.status[0]); |
73 |
printf("temp: %hx\n",calibdata.temp[0]); |
printf("temp: %hx\n",calibdata.temp[0]); |
74 |
printf("DAC: %hx\n",calibdata.DAC[0]); |
printf("DAC1: %hx\n",calibdata.DAC1[0]); |
75 |
|
printf("DAC2: %hx\n",calibdata.DAC2[0]); |
76 |
printf("regist: %hx\n",calibdata.regist[0]); |
printf("regist: %hx\n",calibdata.regist[0]); |
77 |
printf("time: %hx\n",calibdata.time[0]); |
printf("time: %hx\n",calibdata.time[0]); |
78 |
printf("n_tr: %hx\n",calibdata.n_tr); |
printf("n_tr: %hx\n",calibdata.n_tr); |
87 |
|
|
88 |
return err; |
return err; |
89 |
} |
} |
90 |
|
|