X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/rigol/blobdiff_plain/713be7a43ed11947c358fc67c11b9df7b0be204c..483a564bf0578b64b25c68ffabdfdc0fb9f0f2b7:/scope.c?ds=sidebyside diff --git a/scope.c b/scope.c index 3152243..d2bae13 100644 --- a/scope.c +++ b/scope.c @@ -2,51 +2,45 @@ #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 sendscpi(sc, ":KEY:LOCK DISABLE",NULL,0); - return usbtmc_release(sc->usbdev); + return usbtmc_release(sc); } struct scope* initscope(void) { - struct usb_dev_handle *usbdev; struct scope *sc; - usbdev = usbtmc_initscope(); + sc = usbtmc_initscope(); - if (!usbdev) - return NULL; - - 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);