]> git.zerfleddert.de Git - rigol/blob - scope.c
d6aff93bf9a81a71a383cbdd9703ce3674085920
[rigol] / scope.c
1 #include <usb.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <unistd.h>
5 #include <stdint.h>
6
7 #include "scope.h"
8 #include "usbtmc.h"
9
10 /* Just USB for now... */
11 int sendscpi(struct scope* sc, char* cmd, unsigned char *resp, int resplen)
12 {
13 return usbtmc_sendscpi(sc, cmd, resp, resplen);
14 }
15
16 void closescope(struct scope* sc)
17 {
18 return usbtmc_close(sc);
19 }
20
21 void claimscope(struct scope* sc)
22 {
23 return usbtmc_claim(sc);
24 }
25
26 void releasescope(struct scope* sc)
27 {
28 /* Disable keylock, so the user doesn't have to press the 'force'-button */
29 sendscpi(sc, ":KEY:LOCK DISABLE",NULL,0);
30 return usbtmc_release(sc);
31 }
32
33 void resetscope(struct scope* sc)
34 {
35 return usbtmc_reset(sc);
36 }
37
38 struct scope* initscope(void)
39 {
40 struct scope *sc;
41
42 sc = usbtmc_initscope();
43
44 if (!sc) {
45 printf("No scope found.\n");
46 exit(EXIT_FAILURE);
47 }
48
49 claimscope(sc);
50 sendscpi(sc, "*IDN?", (unsigned char*)sc->idn, sizeof(sc->idn));
51 releasescope(sc);
52
53 printf("Scope found (%s)\n", sc->idn);
54
55 return sc;
56 }
57
58 char *scope_idn(struct scope *sc)
59 {
60 return sc->idn;
61 }
Impressum, Datenschutz