]>
git.zerfleddert.de Git - rigol/blob - commands.c
f3dc86c48f9ff760ef65b465c7137bafa537efbf
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 unsigned char* get_lcd(struct usb_dev_handle
*sc
, int *imglen
, int keylock
)
111 unsigned char screen
[320*234];
116 /* Hide "RMT" from screen */
117 l
= usbtmc_sendscpi(sc
, ":KEY:LOCK DISABLE", NULL
, 0);
121 l
= usbtmc_sendscpi(sc
, ":LCD:DATA?", screen
, sizeof(screen
));
123 if (l
!= sizeof(screen
)) {
124 printf ("hmm. didnt' get %d bytes, but %d\n\n", (int)sizeof(screen
), l
);
127 png
= lcd2png(screen
, imglen
);
132 void do_get_screen(struct usb_dev_handle
*sc
)
142 png
= get_lcd(sc
, &imglen
, 1);
149 strftime(filename
, sizeof(filename
), "screen_%Y%m%d-%H%M%S.png", localtime(<
));
150 fd
=open(filename
, O_CREAT
|O_WRONLY
, 0644);
157 ret
= write(fd
, png
, imglen
);
167 printf("Waveform saved as %s\n", filename
);
172 execlp("display", "display", filename
, NULL
);
183 void do_display_screen(struct usb_dev_handle
*sc
)
191 png
= get_lcd(sc
, &imglen
, 1);
197 if (pipe(pipefd
) == -1) {
207 dup2(pipefd
[0], STDIN_FILENO
);
208 execlp("display", "display", "-", NULL
);
217 ret
= write(pipefd
[1], png
, imglen
);