FreeCalypso > hg > fc-rfcal-tools
changeset 5:493987a4527e
fc-cmu200d: signal-gen-sine implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 21 May 2017 07:48:54 +0000 |
parents | 504d3cbb95b5 |
children | d8cbc7a383eb |
files | cmu200/dispatch.c cmu200/signalgen.c |
diffstat | 2 files changed, 34 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/cmu200/dispatch.c Sun May 21 07:21:17 2017 +0000 +++ b/cmu200/dispatch.c Sun May 21 07:48:54 2017 +0000 @@ -10,6 +10,7 @@ extern char *client_cmd_fields[]; extern int client_cmd_nfields; +extern int cmd_signal_gen_sine(); extern int cmd_signal_gen_setup(); cmd_ping() @@ -23,6 +24,7 @@ int (*handler)(); } cmdtab[] = { {"ping", cmd_ping}, + {"signal-gen-sine", cmd_signal_gen_sine}, {"signal-gen-setup", cmd_signal_gen_setup}, {0, 0} };
--- a/cmu200/signalgen.c Sun May 21 07:21:17 2017 +0000 +++ b/cmu200/signalgen.c Sun May 21 07:48:54 2017 +0000 @@ -36,3 +36,35 @@ send_socket_response("+OK\n"); return(0); } + +cmd_signal_gen_sine() +{ + unsigned arfcn, freq_khz; + int offset; + char cmdstr[128]; + + if (current_mode != OP_MODE_SIGNAL_GEN) { + send_socket_response("-Wrong mode\n"); + return(0); + } + if (client_cmd_nfields != 4) { + send_socket_response("-Wrong number of arguments\n"); + return(0); + } + arfcn = atoi(client_cmd_fields[1]); + if (verify_arfcn(arfcn, 0, &freq_khz) < 0) { + send_socket_response("-Invalid ARFCN\n"); + return(0); + } + offset = atoi(client_cmd_fields[2]); + freq_khz += offset; + sprintf(cmdstr, "SOUR:RFG:LEV %s\n", client_cmd_fields[3]); + send_scpi_cmd(cmdstr); + sprintf(cmdstr, "SOUR:RFG:FREQ %u000\n", freq_khz); + send_scpi_cmd(cmdstr); + send_scpi_cmd("INIT:RFG\n"); + send_scpi_cmd("*OPC?\n"); + collect_staropc_response(); + send_socket_response("+OK\n"); + return(0); +}