]>
git.zerfleddert.de Git - rigol/blob - commands.c
75e76d03d65f2a4a2b4095de2ca49233f42811da
12 void do_plot (struct usb_dev_handle
*sc
)
14 unsigned char ch1
[1024], ch2
[1024];
17 static FILE *gnuplot
=NULL
;
20 l
= usbtmc_sendscpi(sc
, ":WAV:DATA? CHANEL1", ch1
, 1024);
23 printf ("hmm. didnt' get 1024 bytes. \n");
26 l
= usbtmc_sendscpi(sc
, ":WAV:DATA? CHANNEL2", ch2
, 1024);
29 printf ("hmm. didnt' get 1024 bytes. \n");
33 gnuplot
= popen ("gnuplot", "w");
36 fp
= fopen ("temp.dat", "w");
37 for (i
=0xd4;i
<0x32c;i
++)
38 //for (i=0;i<0x400;i++)
39 fprintf (fp
, "%d %d\n", 255 - ch1
[i
], 255 - ch2
[i
]);
42 fprintf (gnuplot
, "plot 'temp.dat' using 1 with lines, 'temp.dat' using 2 with lines\n");
49 static double get_float_from_scope (struct usb_dev_handle
*sc
, char *var
)
51 unsigned char buf
[1024];
55 l
= usbtmc_sendscpi(sc
, var
, buf
, 1024);
57 sscanf ((char*)buf
, "%lf", &temp
);
64 void do_get_buf (struct usb_dev_handle
*sc
)
69 unsigned char ch1
[1024];
70 unsigned char data
[512*1024];
73 usbtmc_sendscpi (sc
, ":STOP", NULL
, 0);
75 sampfreq
= get_float_from_scope (sc
, ":ACQ:SAMP?");
77 printf ("Got sampling freq: %g\n", sampfreq
);
79 sprintf (buf
, ":TIM:SCAL %.15f", 50 / sampfreq
);
80 printf ("sending scale cmd: %s\n", buf
);
81 usbtmc_sendscpi (sc
, buf
, NULL
, 0);
86 for (i
=-254*1024;i
< 254*1024;i
+= 600) {
87 sprintf (buf
, ":TIM:OFFSET %.15f", i
/ sampfreq
);
88 printf ("Sending offset cmd: %s\n", buf
);
89 usbtmc_sendscpi (sc
, buf
, NULL
, 0);
91 l
= usbtmc_sendscpi(sc
, ":WAV:DATA? CHANEL1", ch1
, 1024);
94 printf ("hmm. didnt' get 1024 bytes. \n");
98 data
[bp
++] = ch1
[j
+0xd4];
100 printf ("Got %d bytes of data. \n", bp
);
102 fp
= fopen ("ch1.dump", "w");
103 fwrite (data
, bp
, 1, fp
);
106 usbtmc_sendscpi (sc
, ":TIM:OFFSET 0", NULL
, 0);
109 static unsigned char* get_lcd(struct usb_dev_handle
*sc
, int *imglen
)
111 unsigned char screen
[320*234];
115 /* Hide "RMT" from screen */
116 l
= usbtmc_sendscpi(sc
, ":KEY:LOCK DISABLE", NULL
, 0);
119 l
= usbtmc_sendscpi(sc
, ":LCD:DATA?", screen
, sizeof(screen
));
121 if (l
!= sizeof(screen
)) {
122 printf ("hmm. didnt' get %d bytes, but %d\n\n", sizeof(screen
), l
);
125 png
= lcd2png(screen
, imglen
);
130 void do_get_screen(struct usb_dev_handle
*sc
)
140 png
= get_lcd(sc
, &imglen
);
147 strftime(filename
, sizeof(filename
), "screen_%Y%m%d-%H%M%S.png", localtime(<
));
148 fd
=open(filename
, O_CREAT
|O_WRONLY
, 0644);
155 ret
= write(fd
, png
, imglen
);
165 printf("Waveform saved as %s\n", filename
);
170 execlp("display", "display", filename
, NULL
);
181 void do_display_screen(struct usb_dev_handle
*sc
)
189 png
= get_lcd(sc
, &imglen
);
195 if (pipe(pipefd
) == -1) {
205 dup2(pipefd
[0], STDIN_FILENO
);
206 execlp("display", "display", "-", NULL
);
215 ret
= write(pipefd
[1], png
, imglen
);