FreeCalypso > hg > freecalypso-tools
annotate rfcal/cmu200/init.c @ 219:d13ee4ef86c7
rfcal migration
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 20 May 2017 19:43:49 +0000 |
parents | 31d43f0e469a |
children |
rev | line source |
---|---|
194
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module contains the code that fc-cmu200d runs at startup, |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * to put the CMU200 into a known state at the global level. |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdlib.h> |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <string.h> |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <strings.h> |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include "secaddr.h" |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 extern char instrument_response[]; |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 static char id_string[] = "Rohde&Schwarz,CMU"; |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 static void |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 assign_secondary_addr(addr, func) |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 char *func; |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 { |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 char cmdbuf[80]; |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 sprintf(cmdbuf, "SYST:REM:ADDR:SEC %d,\"%s\"\n", addr, func); |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 send_scpi_cmd(cmdbuf); |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 } |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 init_cmu200() |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 { |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 /* Test if we are connected to a CMU */ |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 send_scpi_cmd("*IDN?\n"); |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 collect_instr_response(); |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 if (strncasecmp(instrument_response, id_string, strlen(id_string))) { |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 fprintf(stderr, "error: not connected to a CMU200\n"); |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 exit(1); |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 } |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 /* init commands */ |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 send_scpi_cmd("*SEC 0\n"); |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 send_scpi_cmd("*RST;*OPC?\n"); |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 collect_staropc_response(); |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 send_scpi_cmd("SYST:NONV:DIS\n"); |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 assign_secondary_addr(SECADDR_RF_NSIG, "RF_NSig"); |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 assign_secondary_addr(SECADDR_GSM900MS_NSIG, "GSM900MS_NSig"); |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 assign_secondary_addr(SECADDR_GSM1800MS_NSIG, "GSM1800MS_NSig"); |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 assign_secondary_addr(SECADDR_GSM1900MS_NSIG, "GSM1900MS_NSig"); |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 assign_secondary_addr(SECADDR_GSM850MS_NSIG, "GSM850MS_NSig"); |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 send_scpi_cmd("*OPC?\n"); |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 collect_staropc_response(); |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 printf("CMU200 init complete\n"); |
31d43f0e469a
fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 } |