FreeCalypso > hg > fc-rfcal-tools
annotate cmu200/rfanalyzer.c @ 40:2fb9768fc1e2
fc-cmu200d: VCXO calibration mode generalized into RF analyzer mode
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 27 May 2017 02:38:28 +0000 |
parents | cmu200/vcxocal.c@34c6fbe38daa |
children | 3f4221ef916a |
rev | line source |
---|---|
7
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
40
2fb9768fc1e2
fc-cmu200d: VCXO calibration mode generalized into RF analyzer mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
39
diff
changeset
|
2 * This module implements the RF analyzer functionality |
2fb9768fc1e2
fc-cmu200d: VCXO calibration mode generalized into RF analyzer mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
39
diff
changeset
|
3 * for VCXO and Tx power level calibration support. |
7
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdlib.h> |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <string.h> |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <strings.h> |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include "mode.h" |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include "band.h" |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 |
39
34c6fbe38daa
fc-cmu200d: implemented RF1/RF2 port selection
Mychaela Falconia <falcon@freecalypso.org>
parents:
11
diff
changeset
|
13 extern int cmu200_rf_port; |
34c6fbe38daa
fc-cmu200d: implemented RF1/RF2 port selection
Mychaela Falconia <falcon@freecalypso.org>
parents:
11
diff
changeset
|
14 |
7
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 extern char *client_cmd_fields[]; |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 extern int client_cmd_nfields; |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 extern int current_mode; |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 extern struct band *current_band; |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 |
8
c873a36a16e6
fc-cmu200d: freq-meas implemented without response parsing
Mychaela Falconia <falcon@freecalypso.org>
parents:
7
diff
changeset
|
21 extern char instrument_response[]; |
c873a36a16e6
fc-cmu200d: freq-meas implemented without response parsing
Mychaela Falconia <falcon@freecalypso.org>
parents:
7
diff
changeset
|
22 |
40
2fb9768fc1e2
fc-cmu200d: VCXO calibration mode generalized into RF analyzer mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
39
diff
changeset
|
23 cmd_rfan_setup() |
7
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 { |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 int rc; |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 unsigned arfcn; |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 char cmdstr[32]; |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 if (client_cmd_nfields != 3) { |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 send_socket_response("-Wrong number of arguments\n"); |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 return(0); |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 } |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 stop_signal_gen(); |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 current_mode = OP_MODE_UNDEF; |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 rc = find_named_band(client_cmd_fields[1]); |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 if (rc < 0) { |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 send_socket_response("-Invalid band argument\n"); |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 return(0); |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 } |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 arfcn = atoi(client_cmd_fields[2]); |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 if (verify_arfcn(arfcn, 0, 0) < 0) { |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 send_socket_response("-Invalid ARFCN\n"); |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 return(0); |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 } |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 sprintf(cmdstr, "*SEC %d\n", current_band->secaddr); |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 send_scpi_cmd(cmdstr); |
39
34c6fbe38daa
fc-cmu200d: implemented RF1/RF2 port selection
Mychaela Falconia <falcon@freecalypso.org>
parents:
11
diff
changeset
|
47 sprintf(cmdstr, "INP RF%d\n", cmu200_rf_port); |
34c6fbe38daa
fc-cmu200d: implemented RF1/RF2 port selection
Mychaela Falconia <falcon@freecalypso.org>
parents:
11
diff
changeset
|
48 send_scpi_cmd(cmdstr); |
7
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 sprintf(cmdstr, "RFAN:CHAN %uCH\n", arfcn); |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 send_scpi_cmd(cmdstr); |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 send_scpi_cmd("RFAN:TSEQ GSM5\n"); |
40
2fb9768fc1e2
fc-cmu200d: VCXO calibration mode generalized into RF analyzer mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
39
diff
changeset
|
52 current_mode = OP_MODE_GSM_RFAN; |
7
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 send_socket_response("+OK\n"); |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 return(0); |
948031e6de50
fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 } |
8
c873a36a16e6
fc-cmu200d: freq-meas implemented without response parsing
Mychaela Falconia <falcon@freecalypso.org>
parents:
7
diff
changeset
|
56 |
c873a36a16e6
fc-cmu200d: freq-meas implemented without response parsing
Mychaela Falconia <falcon@freecalypso.org>
parents:
7
diff
changeset
|
57 cmd_freq_meas() |
c873a36a16e6
fc-cmu200d: freq-meas implemented without response parsing
Mychaela Falconia <falcon@freecalypso.org>
parents:
7
diff
changeset
|
58 { |
11
aeffe53e110d
fc-cmu200d: freq-meas works
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
59 char *resp_fields[11]; |
aeffe53e110d
fc-cmu200d: freq-meas works
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
60 char client_resp[128]; |
aeffe53e110d
fc-cmu200d: freq-meas works
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
61 |
40
2fb9768fc1e2
fc-cmu200d: VCXO calibration mode generalized into RF analyzer mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
39
diff
changeset
|
62 if (current_mode != OP_MODE_GSM_RFAN) { |
8
c873a36a16e6
fc-cmu200d: freq-meas implemented without response parsing
Mychaela Falconia <falcon@freecalypso.org>
parents:
7
diff
changeset
|
63 send_socket_response("-Wrong mode\n"); |
c873a36a16e6
fc-cmu200d: freq-meas implemented without response parsing
Mychaela Falconia <falcon@freecalypso.org>
parents:
7
diff
changeset
|
64 return(0); |
c873a36a16e6
fc-cmu200d: freq-meas implemented without response parsing
Mychaela Falconia <falcon@freecalypso.org>
parents:
7
diff
changeset
|
65 } |
c873a36a16e6
fc-cmu200d: freq-meas implemented without response parsing
Mychaela Falconia <falcon@freecalypso.org>
parents:
7
diff
changeset
|
66 send_scpi_cmd("READ:MOD?\n"); |
c873a36a16e6
fc-cmu200d: freq-meas implemented without response parsing
Mychaela Falconia <falcon@freecalypso.org>
parents:
7
diff
changeset
|
67 collect_instr_response(); |
11
aeffe53e110d
fc-cmu200d: freq-meas works
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
68 if (parse_commasep_response(resp_fields, 11) < 0) { |
aeffe53e110d
fc-cmu200d: freq-meas works
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
69 send_socket_response |
aeffe53e110d
fc-cmu200d: freq-meas works
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
70 ("-CMU200 response has wrong number of fields\n"); |
aeffe53e110d
fc-cmu200d: freq-meas works
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
71 return(0); |
aeffe53e110d
fc-cmu200d: freq-meas works
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
72 } |
aeffe53e110d
fc-cmu200d: freq-meas works
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
73 sprintf(client_resp, "+ %s\n", resp_fields[7]); |
aeffe53e110d
fc-cmu200d: freq-meas works
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
74 send_socket_response(client_resp); |
8
c873a36a16e6
fc-cmu200d: freq-meas implemented without response parsing
Mychaela Falconia <falcon@freecalypso.org>
parents:
7
diff
changeset
|
75 return(0); |
c873a36a16e6
fc-cmu200d: freq-meas implemented without response parsing
Mychaela Falconia <falcon@freecalypso.org>
parents:
7
diff
changeset
|
76 } |