FreeCalypso > hg > fc-rfcal-tools
annotate autocal/vcxomeas.c @ 104:7ad0495991ed
autocal: use the new ERROR_RFFAIL exit code
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 09 Dec 2017 07:01:13 +0000 |
parents | b06532c9642f |
children |
rev | line source |
---|---|
24
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module contains the frequency measurement code for fc-rfcal-vcxo. |
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
99
b06532c9642f
fc-rfcal-vcxo: abort on getting a NaN response
Mychaela Falconia <falcon@freecalypso.org>
parents:
25
diff
changeset
|
5 #include <math.h> |
24
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdlib.h> |
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <unistd.h> |
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <rvinterf/l1tm.h> |
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <rvinterf/exitcodes.h> |
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 extern char tsid_response[]; |
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 |
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 float |
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 vcxo_freq_meas(dac, hint) |
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 int dac; |
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 char *hint; |
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 { |
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 char cmd[80]; |
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 double meas; |
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 |
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 printf("Performing frequency measurement at DAC=%d (%s)\n", dac, hint); |
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 do_rfpw(AFC_DAC_VALUE, dac); |
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 usleep(80000); |
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 sprintf(cmd, "freq-meas %s\n", hint); |
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 tsid_command(cmd); |
25
5226dbaa5333
autocal/vcxomeas.c: brown paper bag
Mychaela Falconia <falcon@freecalypso.org>
parents:
24
diff
changeset
|
27 meas = atof(tsid_response + 1); |
24
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 printf("Measured frequency offset %.2f Hz\n", meas); |
99
b06532c9642f
fc-rfcal-vcxo: abort on getting a NaN response
Mychaela Falconia <falcon@freecalypso.org>
parents:
25
diff
changeset
|
29 if (isnan(meas)) { |
b06532c9642f
fc-rfcal-vcxo: abort on getting a NaN response
Mychaela Falconia <falcon@freecalypso.org>
parents:
25
diff
changeset
|
30 printf("Error: got NaN response, aborting\n"); |
b06532c9642f
fc-rfcal-vcxo: abort on getting a NaN response
Mychaela Falconia <falcon@freecalypso.org>
parents:
25
diff
changeset
|
31 do_rfe(STOP_ALL); |
104
7ad0495991ed
autocal: use the new ERROR_RFFAIL exit code
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
32 exit(ERROR_RFFAIL); |
99
b06532c9642f
fc-rfcal-vcxo: abort on getting a NaN response
Mychaela Falconia <falcon@freecalypso.org>
parents:
25
diff
changeset
|
33 } |
24
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 return(meas); |
0b6881281d86
fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 } |