FreeCalypso > hg > fc-rfcal-tools
view cmu200/signalgen.c @ 13:d7e436bf4876
starting autocal
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 21 May 2017 22:58:04 +0000 |
parents | d8cbc7a383eb |
children | 8877634feba5 |
line wrap: on
line source
/* * This module implements the signal generator functionality. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include "mode.h" #include "secaddr.h" extern char *client_cmd_fields[]; extern int client_cmd_nfields; extern int current_mode; cmd_signal_gen_setup() { int rc; char cmdstr[32]; if (client_cmd_nfields != 2) { send_socket_response("-Wrong number of arguments\n"); return(0); } stop_signal_gen(); current_mode = OP_MODE_UNDEF; rc = find_named_band(client_cmd_fields[1]); if (rc < 0) { send_socket_response("-Invalid band argument\n"); return(0); } sprintf(cmdstr, "*SEC %d\n", SECADDR_RF_NSIG); send_scpi_cmd(cmdstr); current_mode = OP_MODE_SIGNAL_GEN; 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); } cmd_signal_gen_off() { stop_signal_gen(); send_socket_response("+OK\n"); return(0); }