X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/rigol/blobdiff_plain/5ef9b719d9b1c393cfbbc535d31c0da048f1c04d..7df76f49adf30ac260c99649678b084c9b6c282b:/commands.c diff --git a/commands.c b/commands.c index f3dc86c..1b243a2 100644 --- a/commands.c +++ b/commands.c @@ -1,15 +1,16 @@ -#include #include #include #include #include #include +#include +#include #include "png.h" -#include "usbtmc.h" +#include "scope.h" #include "commands.h" -void do_plot (struct usb_dev_handle *sc) +void do_plot (struct scope *sc) { unsigned char ch1[1024], ch2[1024]; int i, l; @@ -17,13 +18,13 @@ void do_plot (struct usb_dev_handle *sc) static FILE *gnuplot=NULL; FILE *fp; - l = usbtmc_sendscpi(sc, ":WAV:DATA? CHANEL1", ch1, 1024); + l = sendscpi(sc, ":WAV:DATA? CHANEL1", ch1, 1024); if (l != 1024) { printf ("hmm. didnt' get 1024 bytes. \n"); } - l = usbtmc_sendscpi(sc, ":WAV:DATA? CHANNEL2", ch2, 1024); + l = sendscpi(sc, ":WAV:DATA? CHANNEL2", ch2, 1024); if (l != 1024) { printf ("hmm. didnt' get 1024 bytes. \n"); @@ -46,13 +47,13 @@ void do_plot (struct usb_dev_handle *sc) #define ERROR -1e100 -static double get_float_from_scope (struct usb_dev_handle *sc, char *var) +static double get_float_from_scope (struct scope *sc, char *var) { unsigned char buf[1024]; double temp; int l; - l = usbtmc_sendscpi(sc, var, buf, 1024); + l = sendscpi(sc, var, buf, 1024); if (l > 0) { sscanf ((char*)buf, "%lf", &temp); return temp; @@ -61,7 +62,7 @@ static double get_float_from_scope (struct usb_dev_handle *sc, char *var) } -void do_get_buf (struct usb_dev_handle *sc) +void do_get_buf (struct scope *sc) { FILE *fp; int i, j, l, bp; @@ -70,7 +71,7 @@ void do_get_buf (struct usb_dev_handle *sc) unsigned char data[512*1024]; double sampfreq; - usbtmc_sendscpi (sc, ":STOP", NULL, 0); + sendscpi (sc, ":STOP", NULL, 0); sampfreq = get_float_from_scope (sc, ":ACQ:SAMP?"); @@ -78,7 +79,7 @@ void do_get_buf (struct usb_dev_handle *sc) sprintf (buf, ":TIM:SCAL %.15f", 50 / sampfreq); printf ("sending scale cmd: %s\n", buf); - usbtmc_sendscpi (sc, buf, NULL, 0); + sendscpi (sc, buf, NULL, 0); sleep (1); @@ -86,9 +87,9 @@ void do_get_buf (struct usb_dev_handle *sc) for (i=-254*1024;i< 254*1024;i += 600) { sprintf (buf, ":TIM:OFFSET %.15f", i / sampfreq); printf ("Sending offset cmd: %s\n", buf); - usbtmc_sendscpi (sc, buf, NULL, 0); + sendscpi (sc, buf, NULL, 0); - l = usbtmc_sendscpi(sc, ":WAV:DATA? CHANEL1", ch1, 1024); + l = sendscpi(sc, ":WAV:DATA? CHANEL1", ch1, 1024); if (l != 1024) { printf ("hmm. didnt' get 1024 bytes. \n"); @@ -103,10 +104,10 @@ void do_get_buf (struct usb_dev_handle *sc) fwrite (data, bp, 1, fp); fclose (fp); - usbtmc_sendscpi (sc, ":TIM:OFFSET 0", NULL, 0); + sendscpi (sc, ":TIM:OFFSET 0", NULL, 0); } -unsigned char* get_lcd(struct usb_dev_handle *sc, int *imglen, int keylock) +unsigned char* get_lcd(struct scope *sc, int *imglen, int keylock) { unsigned char screen[320*234]; unsigned char *png; @@ -114,14 +115,15 @@ unsigned char* get_lcd(struct usb_dev_handle *sc, int *imglen, int keylock) if (keylock) { /* Hide "RMT" from screen */ - l = usbtmc_sendscpi(sc, ":KEY:LOCK DISABLE", NULL, 0); + l = sendscpi(sc, ":KEY:LOCK DISABLE", NULL, 0); usleep(30000); } - l = usbtmc_sendscpi(sc, ":LCD:DATA?", screen, sizeof(screen)); + l = sendscpi(sc, ":LCD:DATA?", screen, sizeof(screen)); if (l != sizeof(screen)) { printf ("hmm. didnt' get %d bytes, but %d\n\n", (int)sizeof(screen), l); + return NULL; } png = lcd2png(screen, imglen); @@ -129,7 +131,7 @@ unsigned char* get_lcd(struct usb_dev_handle *sc, int *imglen, int keylock) return png; } -void do_get_screen(struct usb_dev_handle *sc) +void do_get_screen(struct scope *sc) { time_t lt; char filename[256]; @@ -180,7 +182,7 @@ void do_get_screen(struct usb_dev_handle *sc) } } -void do_display_screen(struct usb_dev_handle *sc) +void do_display_screen(struct scope *sc) { unsigned char *png; int imglen;