@@ -183,50 +183,61 @@ float iridium_qpsk_demod_impl::qpskFirstOrderPLL(const gr_complex* x,
183
183
size_t iridium_qpsk_demod_impl::demod_qpsk (
184
184
const gr_complex* burst, size_t n_symbols, int * out, float * level, int * confidence)
185
185
{
186
- int index;
187
- float sum = 0 ;
188
186
float max = 0 ;
189
187
int low_count = 0 ;
190
- int n_ok = 0 ;
188
+ int n = 0 ;
189
+ float offsets[n_symbols];
191
190
192
191
volk_32fc_magnitude_32f (d_magnitude_f, burst, n_symbols);
193
192
194
- for (index = 0 ; index < n_symbols; index++) {
195
- sum += d_magnitude_f[index];
196
- if (max < d_magnitude_f[index]) {
197
- max = d_magnitude_f[index];
193
+ for (int i = 0 ; i < n_symbols; i++) {
194
+ if (max < d_magnitude_f[i]) {
195
+ max = d_magnitude_f[i];
198
196
}
199
197
200
198
// demodulating circuit
201
- if (burst[index ].real () >= 0 && burst[index ].imag () >= 0 ) {
202
- out[index ] = d_symbol_mapping[0 ];
203
- } else if (burst[index ].real () >= 0 && burst[index ].imag () < 0 ) {
204
- out[index ] = d_symbol_mapping[3 ];
205
- } else if (burst[index ].real () < 0 && burst[index ].imag () < 0 ) {
206
- out[index ] = d_symbol_mapping[2 ];
199
+ if (burst[i ].real () >= 0 && burst[i ].imag () >= 0 ) {
200
+ out[i ] = d_symbol_mapping[0 ];
201
+ } else if (burst[i ].real () >= 0 && burst[i ].imag () < 0 ) {
202
+ out[i ] = d_symbol_mapping[3 ];
203
+ } else if (burst[i ].real () < 0 && burst[i ].imag () < 0 ) {
204
+ out[i ] = d_symbol_mapping[2 ];
207
205
} else {
208
- out[index ] = d_symbol_mapping[1 ];
206
+ out[i ] = d_symbol_mapping[1 ];
209
207
}
210
208
211
209
// Keep some quality estimate
212
210
// If the phase is off too much, we lower the reported confidence
213
- int phase = (gr::fast_atan2f (burst[index ]) + M_PI) * 180 / M_PI;
211
+ int phase = (gr::fast_atan2f (burst[i ]) + M_PI) * 180 / M_PI;
214
212
int offset = 45 - (phase % 90 );
215
- if (abs (offset) <= 22 ) {
216
- n_ok++;
217
- }
213
+ offsets[i] = offset;
218
214
219
- if (d_magnitude_f[index] < max / 8 .) {
215
+ n++;
216
+ if (d_magnitude_f[i] < max / 8 .) {
220
217
low_count++;
221
- if (low_count > 2 ) {
218
+ if (low_count == 3 ) {
219
+ // We don't want to consider noise at the end of the frame
220
+ n -= 3 ;
222
221
break ;
223
222
}
223
+ } else {
224
+ low_count = 0 ;
225
+ }
226
+ }
227
+
228
+ int n_ok = 0 ;
229
+ float sum = 0 ;
230
+
231
+ for (int i=0 ; i < n; i++) {
232
+ if (abs (offsets[i]) <= 22 ) {
233
+ n_ok++;
224
234
}
235
+ sum += d_magnitude_f[i];
225
236
}
226
237
227
- *level = sum / index ;
228
- *confidence = (int )(100 . * n_ok / index );
229
- return index ;
238
+ *level = sum / n ;
239
+ *confidence = (int )(100 . * n_ok / n );
240
+ return n ;
230
241
}
231
242
232
243
void iridium_qpsk_demod_impl::decode_deqpsk (int * demodulated_burst, size_t n_symbols)
0 commit comments