]> git.zerfleddert.de Git - rigol/blobdiff - scope.c
export data through webinterface
[rigol] / scope.c
diff --git a/scope.c b/scope.c
index 43439ff9219284b3299e7d903a262cd2f5b4ad63..09c9b8d1c0cd25a08e3f913b623efa185125b299 100644 (file)
--- a/scope.c
+++ b/scope.c
@@ -8,6 +8,17 @@
 #include "scope.h"
 #include "usbtmc.h"
 
+#define DATASIZE 10240
+
+#define COPY_SCOPE_STRING(sc, cmd, dst) { \
+                                               char *buf; \
+                                               buf = scope_get_string(sc, cmd, sizeof(dst)); \
+                                               if (buf) { \
+                                                       strcpy(dst, buf); \
+                                                       free(buf); \
+                                               }\
+                                       }
+
 /* Just USB for now... */
 int sendscpi(struct scope* sc, char* cmd, unsigned char *resp, int resplen)
 {
@@ -48,7 +59,7 @@ struct scope* initscope(void)
        }
 
        claimscope(sc);
-       sendscpi(sc, "*IDN?", (unsigned char*)sc->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");
Impressum, Datenschutz