X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/rigol/blobdiff_plain/713be7a43ed11947c358fc67c11b9df7b0be204c..bd29c60e53e501684134598436c05bb25915cb1c:/scope.c diff --git a/scope.c b/scope.c index 3152243..c316ee5 100644 --- a/scope.c +++ b/scope.c @@ -1,52 +1,50 @@ -#include #include #include #include +#include -#include "usbtmc.h" #include "scope.h" +#include "usbtmc.h" /* Just USB for now... */ int sendscpi(struct scope* sc, char* cmd, unsigned char *resp, int resplen) { - return usbtmc_sendscpi(sc->usbdev, cmd, resp, resplen); + return usbtmc_sendscpi(sc, cmd, resp, resplen); } void closescope(struct scope* sc) { - return usbtmc_close(sc->usbdev); + return usbtmc_close(sc); } void claimscope(struct scope* sc) { - return usbtmc_claim(sc->usbdev); + return usbtmc_claim(sc); } void releasescope(struct scope* sc) { - //Disable keylock, so the user doesn't have to press the 'force'-button + /* Disable keylock, so the user doesn't have to press the 'force'-button */ sendscpi(sc, ":KEY:LOCK DISABLE",NULL,0); - return usbtmc_release(sc->usbdev); + return usbtmc_release(sc); +} + +void resetscope(struct scope* sc) +{ + return usbtmc_reset(sc); } struct scope* initscope(void) { - struct usb_dev_handle *usbdev; struct scope *sc; - usbdev = usbtmc_initscope(); - - if (!usbdev) - return NULL; + sc = usbtmc_initscope(); - sc = calloc(1, sizeof(struct scope)); - if (sc == NULL) { - perror("malloc"); + if (!sc) { + printf("No scope found.\n"); exit(EXIT_FAILURE); } - sc->usbdev = usbdev; - claimscope(sc); sendscpi(sc, "*IDN?", (unsigned char*)sc->idn, sizeof(sc->idn)); releasescope(sc);