diff cmu200/signalgen.c @ 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
line wrap: on
line diff
--- 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);
+}