]> git.zerfleddert.de Git - rigol/blob - scope.c
d2bae1324d3bfe42a67d46f491febc0c07ec0e49
[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 struct scope* initscope(void)
34 {
35 struct scope *sc;
36
37 sc = usbtmc_initscope();
38
39 if (!sc) {
40 printf("No scope found.\n");
41 exit(EXIT_FAILURE);
42 }
43
44 claimscope(sc);
45 sendscpi(sc, "*IDN?", (unsigned char*)sc->idn, sizeof(sc->idn));
46 releasescope(sc);
47
48 printf("Scope found (%s)\n", sc->idn);
49
50 return sc;
51 }
52
53 char *scope_idn(struct scope *sc)
54 {
55 return sc->idn;
56 }
Impressum, Datenschutz