sc->status.math.displayed,
sc->status.fft.displayed);
+ send_text(s, "<br>Data: ");
+ send_text(s, "<a href=\"/cgi-bin/data?CHAN1\">Channel 1</a> ");
+ send_text(s, "<a href=\"/cgi-bin/data?CHAN2\">Channel 2</a> ");
+ send_text(s, "<a href=\"/cgi-bin/data?DIG\">Digital</a> ");
+ send_text(s, "<a href=\"/cgi-bin/data?MATH\">Math</a> ");
+ send_text(s, "<a href=\"/cgi-bin/data?FFT\">FFT</a><br>");
+
send_text(s, "<br>\n");
send_text(s, "<form method=\"get\" action=\"\">\n");
send_text(s, "<input type=\"text\" name=\"cmd\" value=\"");
free(png);
}
+static void serve_data(int s, struct scope *sc, char *source)
+{
+ char *data;
+ int len;
+ int i;
+
+ send_text(s, "HTTP/1.0 200 OK\n");
+ send_text(s, "Content-type: text/plain\n\n");
+
+ claimscope(sc);
+ data = scope_get_data(sc, source, &len);
+ releasescope(sc);
+
+ if (data != NULL) {
+ for (i = 0; i < (len-1); i++) {
+ send_text(s, "%d,", data[i]);
+ }
+ send_text(s, "%d", data[len-1]);
+ free(data);
+ }
+}
+
static void serve_404(int s)
{
send_text(s, "HTTP/1.0 404 Not found\n");
serve_index(s, sc, param);
} else if (strcmp("/cgi-bin/lcd", file) == 0) {
serve_lcd(s, sc);
+ } else if (strcmp("/cgi-bin/data", file) == 0) {
+ serve_data(s, sc, param);
} else {
serve_404(s);
}
#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)
{
}
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);
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;
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");