FreeCalypso > hg > fc-rfcal-tools
diff cmu200/sercmd.c @ 11:aeffe53e110d
fc-cmu200d: freq-meas works
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 21 May 2017 19:22:11 +0000 |
parents | bd62be88259d |
children | 99f753d4ccaf |
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); +}