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