From: Michael Gernoth Date: Sat, 19 Jun 2010 17:16:16 +0000 (+0200) Subject: export data through webinterface X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/rigol/commitdiff_plain/8e60ee60c04ec12ceac8f3cbc04cebe7a9c1efd8 export data through webinterface --- diff --git a/rigold.c b/rigold.c index 93a5eb0..955975a 100644 --- a/rigold.c +++ b/rigold.c @@ -196,6 +196,13 @@ static void serve_index(int s, struct scope *sc, char *param) sc->status.math.displayed, sc->status.fft.displayed); + send_text(s, "
Data: "); + send_text(s, "Channel 1 "); + send_text(s, "Channel 2 "); + send_text(s, "Digital "); + send_text(s, "Math "); + send_text(s, "FFT
"); + send_text(s, "
\n"); send_text(s, "
\n"); send_text(s, "idn, sizeof(sc->idn)); + COPY_SCOPE_STRING(sc, "*IDN?", sc->idn); releasescope(sc); printf("Scope found (%s)\n", sc->idn); @@ -61,15 +72,6 @@ char *scope_idn(struct scope *sc) return sc->idn; } -#define COPY_SCOPE_STRING(sc, cmd, dst) { \ - char *buf; \ - buf = scope_get_string(sc, cmd, sizeof(dst)); \ - if (buf) { \ - strcpy(dst, buf); \ - free(buf); \ - }\ - } - char *scope_get_string(struct scope *sc, char *cmd, int maxlen) { unsigned char *buf; @@ -147,6 +149,22 @@ double scope_get_double(struct scope *sc, char*cmd) return ret; } +char *scope_get_data(struct scope *sc, char *source, int *len) +{ + char *data = NULL; + char cmd[128]; + + if ((data = malloc(DATASIZE)) == NULL) { + perror("malloc"); + return NULL; + } + + snprintf(cmd, sizeof(cmd), ":WAV:DATA? %s", source); + *len = sendscpi(sc, cmd, (unsigned char*)data, DATASIZE); + + return data; +} + void update_scope_measurements(struct scope *sc) { sc->status.measure.ch1.vpp = scope_get_double(sc, ":MEAS:VPP? CHAN1"); diff --git a/scope.h b/scope.h index dba5670..a74809b 100644 --- a/scope.h +++ b/scope.h @@ -133,3 +133,4 @@ int scope_get_int(struct scope *sc, char *cmd); double scope_get_double(struct scope *sc, char*cmd); void update_scope_measurements(struct scope *sc); int update_scope_status(struct scope *sc); +char *scope_get_data(struct scope *sc, char *source, int *len);