4 #include <rtsSystems.h>
5 #include <daqFormats.h>
8 #include <DAQ_READER/daq_det.h>
12 const char *
hdrs[3] = {
18 char *bsmd_reader(
char *e,
struct bsmd_desc *bsmd_d)
20 struct EMCP *emcp = (
struct EMCP *)e ;
25 memset(bsmd_d,0,
sizeof(
struct bsmd_desc)) ;
27 LOG(DBG,
"BSMD: %p",emcp) ;
32 if(checkBank(emcp->bh.bank_type, CHAR_EMCP)<0)
return 0 ;
34 off = b2h32(emcp->sec[1].off) ;
35 len = b2h32(emcp->sec[1].len) ;
36 LOG(DBG,
"BSMD: sector 1: %d %d",off,len) ;
38 if((len==0) || (off==0))
return 0 ;
40 struct EMCSECP *emcsecp = (
struct EMCSECP *)((u_int *)emcp + off) ;
42 if(checkBank(emcsecp->bh.bank_type, CHAR_EMCSECP)<0)
return 0 ;
44 int fibers = (b2h32(emcsecp->bh.length)-10) / 2 ;
46 LOG(DBG,
"BSMD: %d fibers",fibers) ;
48 for(
int f=0;f<fibers;f++) {
50 len = b2h32(emcsecp->fiber[f].len) ;
51 off = b2h32(emcsecp->fiber[f].off) ;
53 if((len==0) || (off==0)) continue ;
55 struct EMCRBP *emcrbp = (
struct EMCRBP *)((u_int *)emcsecp + off) ;
57 if(checkBank(emcrbp->bh.bank_type, CHAR_EMCRBP)< 0)
return 0 ;
59 int banks = (b2h32(emcrbp->bh.length) - 10)/2 ;
61 LOG(DBG,
"BSMD: fiber %d: %d banks",f,banks) ;
63 for(
int b=0;b<banks;b++) {
65 len = b2h32(emcrbp->banks[b].len) ;
66 off = b2h32(emcrbp->banks[b].off) ;
68 if((len==0) || (off==0)) continue ;
72 if(checkBank(emcadc->bh.bank_type, (
char *)
hdrs[b])<0)
return 0 ;
78 bsmd_d->bytes[f][b] = b2h32(emcadc->bh.length)*4 - 40 ;
79 bsmd_d->endian[f][b] = 1 ;
82 bsmd_d->bytes[f][b] = l2h32(emcadc->bh.length)*4 - 40 ;
83 bsmd_d->endian[f][b] = 0 ;
86 bsmd_d->dta[f][b] = ((
char *)emcadc + 40) ;
88 LOG(DBG,
"BSMD: fiber %d: bank %d: bytes %d",f,b,bsmd_d->bytes[f][b]) ;
92 LOG(DBG,
"bsmd_reader: found some %d",found_some) ;
94 if(found_some)
return (
char *)bsmd_d ;