]> git.zerfleddert.de Git - rigol/blame - scope.c
usbtmc now uses struct scope
[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{
28 //Disable keylock, so the user doesn't have to press the 'force'-button
29 sendscpi(sc, ":KEY:LOCK DISABLE",NULL,0);
7906b395 30 return usbtmc_release(sc);
713be7a4
MG
31}
32
33struct scope* initscope(void)
34{
713be7a4
MG
35 struct scope *sc;
36
7906b395 37 sc = usbtmc_initscope();
713be7a4 38
7906b395 39 if (!sc) {
2999345d
MG
40 printf("No scope found.\n");
41 exit(EXIT_FAILURE);
42 }
713be7a4 43
713be7a4
MG
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
53char *scope_idn(struct scope *sc)
54{
55 return sc->idn;
56}
Impressum, Datenschutz