]> git.zerfleddert.de Git - rigol/blobdiff - rigol.c
add abstraction for scope-access
[rigol] / rigol.c
diff --git a/rigol.c b/rigol.c
index 22a5ceac242f798215b7eaf0003200f5a1c83b68..06ebacbc1a3d9dc8ea74cd3d48db9694bfc1df33 100644 (file)
--- a/rigol.c
+++ b/rigol.c
@@ -8,7 +8,6 @@ rmmod uhci_hcd; modprobe uhci_hcd
 (or alternately: use ohci_hcd) if that happens and you should be fine.
  */
 
-#include <usb.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -23,7 +22,7 @@ rmmod uhci_hcd; modprobe uhci_hcd
 #include <readline/readline.h>
 #include <readline/history.h>
 
-#include "usbtmc.h"
+#include "scope.h"
 #include "commands.h"
 
 #define MIN(a,b) (((a)<(b))?(a):(b))
@@ -96,14 +95,15 @@ void child_reaper(int sig)
 
 int main(int argc, char **argv) 
 {
-       struct usb_dev_handle *sc;
+       struct scope *sc;
        char *scpi;
        unsigned char *buff;
        int l;
        struct sigaction act;
 
        //Initialize scope
-       sc = usbtmc_initscope();
+       sc = initscope();
+       claimscope(sc);
        buff = malloc (1024*1024); 
        if (buff == NULL) {
                perror("malloc");
@@ -135,11 +135,15 @@ int main(int argc, char **argv)
                        continue;
                }
                if (strncmp (scpi, "databuf", 7) == 0) {
-                       do_get_buf (sc);
+                       do_get_buf(sc);
                        continue;
                }
                if (strncmp (scpi, "screen", 6) == 0) {
-                       do_get_screen (sc);
+                       do_get_screen(sc);
+                       continue;
+               }
+               if (strncmp (scpi, "display", 7) == 0) {
+                       do_display_screen(sc);
                        continue;
                }
 
@@ -148,21 +152,17 @@ int main(int argc, char **argv)
                //printb (scpi, l+2); 
                if (strchr (scpi, '?')) {
                        //printf ("Expecting reply\n");
-                       l = usbtmc_sendscpi(sc, scpi, buff, 1024*1024);
+                       l = sendscpi(sc, scpi, buff, 1024*1024);
                        //printf ("Got replylen = %d.\n", l); 
                        buff[l] = 0; //zero-terminate
                        printb (buff, l);
                } else {
                        //printf ("No reply expected\n");
-                       l=usbtmc_sendscpi(sc,scpi,NULL,0);
+                       l=sendscpi(sc,scpi,NULL,0);
                }
                free (scpi);
        }
-       //Disable keylock, so the user doesn't have to press the 'force'-button
-       l=usbtmc_sendscpi(sc, ":KEY:LOCK DISABLE",NULL,0); 
-
-       //Free up and exit
-       usb_release_interface(sc,0);
-       usb_close(sc);
+       releasescope(sc);
+       closescope(sc);
        return 0;
 }
Impressum, Datenschutz