2 * Copyright 2006 Free Software Foundation, Inc.
4 * This file is part of GNU Radio
6 * GNU Radio is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * GNU Radio is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Radio; see the file COPYING. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street,
19 * Boston, MA 02110-1301, USA.
26 const static int samples = 250;
29 static complex<float> buffer[samples];
31 int main(int argc, char *argv)
33 ezdop *dop = new ezdop();
35 printf("Initializing EZDOP...");
40 printf("EZDOP reports %s.\n", dop->is_online() ? "online" : "offline");
42 printf("Setting EZDOP rate...");
43 if (dop->set_rate(rate))
48 printf("Telling EZDOP to rotate...");
54 printf("Telling EZDOP to stream...");
62 for (int i = 0; i < chunks; i++) {
63 printf("Asking EZDOP for %i samples...", samples);
64 int rd = dop->read_iq(buffer, samples, volume);
65 printf("got %i --- ", rd);
69 complex<float> average = complex<float>(0.0, 0.0);
70 for (int j = 0; j < rd; j++) {
74 float I = average.real()/rd;
75 float Q = average.imag()/rd;
76 float M = std::sqrt(I*I+Q*Q);
77 float dbfs = 20*std::log(M/1.4142135);
79 printf("I=%f Q=%f M=%f dbfs=%f\n", I, Q, M, dbfs);
82 printf("Telling EZDOP to stop streaming...");
83 if (dop->stop_streaming())
88 printf("Telling EZDOP to stop stop rotating...");
89 if (dop->stop_rotating())
94 printf("Releasing EZDOP...");