FreeCalypso > hg > fc-rfcal-tools
changeset 11:aeffe53e110d
fc-cmu200d: freq-meas works
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 21 May 2017 19:22:11 +0000 |
parents | 34a66394bea0 |
children | d06985c1f13c |
files | cmu200/sercmd.c cmu200/vcxocal.c |
diffstat | 2 files changed, 34 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/cmu200/sercmd.c Sun May 21 18:57:44 2017 +0000 +++ b/cmu200/sercmd.c Sun May 21 19:22:11 2017 +0000 @@ -44,15 +44,37 @@ break; } instrument_response[pos-1] = '\0'; + if (pos >= 2 && instrument_response[pos-2] == '\r') + instrument_response[pos-2] = '\0'; printf("Instrument response: %s\n", instrument_response); } collect_staropc_response() { collect_instr_response(); - if (instrument_response[0] != '1' || - instrument_response[1] && !isspace(instrument_response[1])) { + if (instrument_response[0] != '1' || instrument_response[1]) { fprintf(stderr, "error: unexpected response to *OPC?\n"); exit(1); } } + +parse_commasep_response(argv, expect_count) + char **argv; +{ + char *cp, *sp; + int i; + + cp = instrument_response; + for (i = 0; i < expect_count - 1; i++) { + argv[i] = cp; + sp = index(cp, ','); + if (!sp) + return(-1); + *sp = '\0'; + cp = sp + 1; + } + argv[i] = cp; + if (index(cp, ',')) + return(-1); + return(0); +}
--- a/cmu200/vcxocal.c Sun May 21 18:57:44 2017 +0000 +++ b/cmu200/vcxocal.c Sun May 21 19:22:11 2017 +0000 @@ -51,13 +51,21 @@ cmd_freq_meas() { + char *resp_fields[11]; + char client_resp[128]; + if (current_mode != OP_MODE_VCXO_CAL) { send_socket_response("-Wrong mode\n"); return(0); } send_scpi_cmd("READ:MOD?\n"); collect_instr_response(); - /* response parsing and freq offset extraction to be implemented */ - send_socket_response("+ TBD\n"); + if (parse_commasep_response(resp_fields, 11) < 0) { + send_socket_response + ("-CMU200 response has wrong number of fields\n"); + return(0); + } + sprintf(client_resp, "+ %s\n", resp_fields[7]); + send_socket_response(client_resp); return(0); }