FreeCalypso > hg > fc-rfcal-tools
comparison autocal/l1meas.c @ 48:201f27bd8dca
autocal/l1meas.c: implemented reading of auto-stats
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 27 May 2017 07:03:08 +0000 |
parents | 98abe6bd2042 |
children | 1a0dbc746d57 |
comparison
equal
deleted
inserted
replaced
47:e86779d5445c | 48:201f27bd8dca |
---|---|
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <rvinterf/pktmux.h> | 9 #include <rvinterf/pktmux.h> |
10 #include <rvinterf/tm3.h> | 10 #include <rvinterf/tm3.h> |
11 #include <rvinterf/l1tm.h> | 11 #include <rvinterf/l1tm.h> |
12 #include <rvinterf/exitcodes.h> | 12 #include <rvinterf/exitcodes.h> |
13 #include "l1stats.h" | |
13 | 14 |
14 extern u_char rvi_msg[]; | 15 extern u_char rvi_msg[]; |
15 extern int rvi_msg_len; | 16 extern int rvi_msg_len; |
16 | 17 |
17 do_scw(index, value) | 18 do_scw(index, value) |
37 fprintf(stderr, "DUT error: scw response wrong index\n"); | 38 fprintf(stderr, "DUT error: scw response wrong index\n"); |
38 exit(ERROR_TARGET); | 39 exit(ERROR_TARGET); |
39 } | 40 } |
40 return(0); | 41 return(0); |
41 } | 42 } |
43 | |
44 collect_auto_stats(sb) | |
45 struct l1stats *sb; | |
46 { | |
47 unsigned type, bitmask, offset; | |
48 int expect_len; | |
49 | |
50 collect_extra_pkt_from_target(); | |
51 l1tm_resp_sanity_check(STATS_READ); | |
52 if (rvi_msg[3]) { | |
53 fprintf(stderr, "DUT error %u in auto-stats message\n", | |
54 rvi_msg[3]); | |
55 exit(ERROR_TARGET); | |
56 } | |
57 if (rvi_msg_len < 9) { | |
58 fprintf(stderr, "DUT error: auto-stats msg too short\n"); | |
59 exit(ERROR_TARGET); | |
60 } | |
61 type = rvi_msg[4] | (rvi_msg[5] << 8); | |
62 bitmask = rvi_msg[6] | (rvi_msg[7] << 8); | |
63 if (type < 1 || type > 2) { | |
64 fprintf(stderr, "DUT error: invalid type in auto-stats msg\n"); | |
65 exit(ERROR_TARGET); | |
66 } | |
67 if (bitmask & 0x0300) { | |
68 fprintf(stderr, | |
69 "DUT error: invalid bitmask in auto-stats msg\n"); | |
70 exit(ERROR_TARGET); | |
71 } | |
72 expect_len = 9; | |
73 if (bitmask & RSSI) | |
74 expect_len += 2; | |
75 if (bitmask & DSP_PM) | |
76 expect_len += 2; | |
77 if (bitmask & ANGLE_MEAN) | |
78 expect_len += 4; | |
79 if (bitmask & ANGLE_VAR) | |
80 expect_len += 4; | |
81 if (bitmask & ANGLE_MIN) | |
82 expect_len += 4; | |
83 if (bitmask & ANGLE_MAX) | |
84 expect_len += 4; | |
85 if (bitmask & SNR_MEAN) | |
86 expect_len += 4; | |
87 if (bitmask & SNR_VAR) | |
88 expect_len += 4; | |
89 if (bitmask & TOA_MEAN) | |
90 expect_len += 4; | |
91 if (bitmask & TOA_VAR) | |
92 expect_len += 4; | |
93 if (bitmask & FRAME_NUMBER) | |
94 expect_len += 4; | |
95 if (bitmask & RUNS) | |
96 expect_len += 4; | |
97 if (bitmask & SUCCESSES) | |
98 expect_len += 4; | |
99 if (bitmask & BSIC) | |
100 expect_len += 2; | |
101 if (rvi_msg_len != expect_len) { | |
102 fprintf(stderr, "DUT error: auto-stats msg wrong length\n"); | |
103 exit(ERROR_TARGET); | |
104 } | |
105 sb->type = type; | |
106 sb->bitmask = bitmask; | |
107 offset = 8; | |
108 if (bitmask & RSSI) { | |
109 sb->rssi = rvi_msg[offset] | (rvi_msg[offset+1] << 8); | |
110 offset += 2; | |
111 } | |
112 if (bitmask & DSP_PM) { | |
113 sb->dsp_pm = rvi_msg[offset] | (rvi_msg[offset+1] << 8); | |
114 offset += 2; | |
115 } | |
116 if (bitmask & ANGLE_MEAN) { | |
117 sb->angle_mean = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | | |
118 (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); | |
119 offset += 4; | |
120 } | |
121 if (bitmask & ANGLE_VAR) { | |
122 sb->angle_var = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | | |
123 (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); | |
124 offset += 4; | |
125 } | |
126 if (bitmask & ANGLE_MIN) { | |
127 sb->angle_min = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | | |
128 (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); | |
129 offset += 4; | |
130 } | |
131 if (bitmask & ANGLE_MAX) { | |
132 sb->angle_max = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | | |
133 (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); | |
134 offset += 4; | |
135 } | |
136 if (bitmask & SNR_MEAN) { | |
137 sb->snr_mean = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | | |
138 (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); | |
139 offset += 4; | |
140 } | |
141 if (bitmask & SNR_VAR) { | |
142 sb->snr_var = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | | |
143 (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); | |
144 offset += 4; | |
145 } | |
146 if (bitmask & TOA_MEAN) { | |
147 sb->toa_mean = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | | |
148 (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); | |
149 offset += 4; | |
150 } | |
151 if (bitmask & TOA_VAR) { | |
152 sb->toa_var = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | | |
153 (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); | |
154 offset += 4; | |
155 } | |
156 if (bitmask & FRAME_NUMBER) { | |
157 sb->frame_number = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | | |
158 (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); | |
159 offset += 4; | |
160 } | |
161 if (bitmask & RUNS) { | |
162 sb->runs = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | | |
163 (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); | |
164 offset += 4; | |
165 } | |
166 if (bitmask & SUCCESSES) { | |
167 sb->successes = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | | |
168 (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); | |
169 offset += 4; | |
170 } | |
171 if (bitmask & BSIC) { | |
172 sb->bsic = rvi_msg[offset] | (rvi_msg[offset+1] << 8); | |
173 offset += 2; | |
174 } | |
175 return(0); | |
176 } |