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